Type tSnake Field xpos Field ypos Field snaketype End Type Const head = 1 Const body = 2 Const tail = 3 Snake.tSnake = New tSnake Snake\xpos = 10 Snake\ypos = 10 Snake\snaketype = head Snake.tSnake = New tSnake Snake\xpos = 10 Snake\ypos = 11 Snake\snaketype = body Snake.tSnake = New tSnake Snake\xpos = 10 Snake\ypos = 12 Snake\snaketype = tail Dim body(3) body(1) = LoadImage "Head.bmp" body(2) = LoadImage "Body.bmp" body(3) = LoadImage "Tail.bmp" Graphics 640, 480, 0, 2 SetBuffer BackBuffer() While Not KeyHit(1) ;input section ;blah, blah, blah newXpos = ?? newYpos = ?? ;logic section lastXpos = newXpos lastYpos = newYpos For Snake.tSnake = Each tSnake tempXpos = Snake\xpos tempYpos = Snake\ypos Snake\xpos = lastXpos Snake\ypos = lastYpos lastXpos = tempXpos lastYpos = tempYpos Next If FoodEaten = TRUE Snake.tSnake = Last tSnake Snake\snaketype = body Snake.tSnake = New tSnake Snake\xpos = lastXpos Snake\ypos = lastYpos Snake\snaketype = tail EndIf ;drawing section CLS For Snake.tSnake = each tSnake DrawImage body(Snake\snaketype), Snake\xpos * 32, Snake\ypos * 32 Next Flip Wend EndI just realized that my code will always draw the images the same way regardless of the direction of the next body part. I'm sure you can figure out how to make that work though.
How to start a snake game?
Blitz3D Forums/Blitz3D Beginners Area/How to start a snake game?The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.