One question though. Using Similar code my pic animates properly but if i have it constanly animating movement around the map seems very sluggish and choppy compared to moving with no animation. Is there a way to speed this up or is there a problem with my code?
Code: Select all
;--Variable Declarations--
imagex.l=800
imagey.l=600
points.l=0
;--pointer section--
Structure POINT
X.l
Y.L
EndStructure
NewList Burger.Point()
AddElement(burger())
Burger()\x=125
Burger()\y=115
AddElement(burger())
Burger()\x=160
Burger()\y=115
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitSound() = 0
MessageRequester("error", "Can't open", 0)
End
EndIf
If OpenScreen(1024,768,16,"Gut Check")
;--Sound Loader--
UseOGGSoundDecoder()
LoadSound(2, "Chomp.wav")
LoadSound(1, "opening.wav")
;PlaySound(1, 0) ;commented out during alpha phase
UseJPEGImageDecoder()
;--Sprite Loader--
LoadSprite(0,"level.jpg",0)
LoadSprite(2, "walls.jpg",0)
LoadSprite(1,"anim.jpg",0)
StartDrawing(SpriteOutput(1))
StopDrawing()
LoadSprite(1000, "smburger2.jpg", 0)
StartDrawing(SpriteOutput(1000))
StopDrawing()
LoadFont(1,"Arial",20,#PB_Font_Underline)
;--Game Engine--
Repeat
FlipBuffers()
ClearScreen(0,0,0)
ExamineKeyboard()
If KeyboardPushed(#PB_Key_A) Or KeyboardPushed(#PB_Key_Left)
Imagex= imagex-3
Gosub WallCheck
EndIf
If KeyboardPushed(#PB_Key_D) Or KeyboardPushed(#PB_Key_Right)
Imagex= imagex+3
Gosub WallCheck
EndIf
If KeyboardPushed(#PB_Key_W) Or KeyboardPushed(#PB_Key_Up)
Imagey= imagey-3
Gosub WallCheck
EndIf
If KeyboardPushed(#PB_Key_S) Or KeyboardPushed(#PB_Key_Down)
Imagey= imagey+3
Gosub WallCheck
EndIf
Gosub Update_back
Gosub animate
Gosub Burger_count
Gosub Check_score
Until KeyboardPushed(#PB_Key_Escape)
EndIf
End
;--Update Screen Functions--
Update_back:
DisplaySprite(0,0,0)
Return
animate:
ClipSprite(1,x,0,31,32)
DisplayTransparentSprite(1,imagex, imagey)
Delay(110)
x+31:If x>61:x=0:EndIf
Return
;--burger checking--
Burger_count:
ForEach Burger()
DisplayTransparentSprite(1000,burger()\x,Burger()\y)
If SpriteCollision(1, imagex, imagey, 1000, burger()\x, burger()\y)
LoadSound(2, "chomp.wav")
;PlaySound(2, 0)
points + 25
DeleteElement(Burger())
Continue
EndIf
Next
Return
;--Wall Checking Procedure
WallCheck:
;If SpritePixelCollision(1, imagex,imagey, 2, 262,415)
; imagex= imagex+2
;EndIf
Return
;--Scoring Algorithm--
Check_score:
StartDrawing(ScreenOutput())
DrawingMode(1)
DrawingFont(UseFont(1))
FrontColor(255,255,255):Locate(700,100):DrawText("HIGH SCORE: " + Str(points))
FrontColor(255,255,255):Locate(700,200):DrawText("1UP: " + Str(points))
StopDrawing()
Return
just an fyi this game is made soley to poke fun a t a co-worker