Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Snake???

Author
Message
MjC
20
Years of Service
User Offline
Joined: 19th May 2003
Location:
Posted: 20th May 2003 05:59
I have the head of the snake but I don't know how to add body parts each time it eats somethin... I don't get how to make all the body parts follow the head of the snake either. If anyone could point me in the right spot it would be great. Sorry if I missed a tut or resource somewhere!!!!!!!!!!!!!!

thx

MjC
Joe Cooning
21
Years of Service
User Offline
Joined: 29th Mar 2003
Location: United States
Posted: 22nd May 2003 00:02
Try something like this.


'snake array
Dim snake(maximum # of body Parts,2)

For i=1 to max # of body parts
Make Object plain i,size x,size y
texture it
Hide object i
next i

sync on
While(not collided with anything bad){
If UpKey=1 Then y=y+1
If DownKey=1 Then y=y-1
If RightKey=1 Then x=x-1
If LeftKey=1 Then x=x+1

'display body parts
If snake head eats something Then bodyPart=bodyPart+1 : Show object bodyPart

move_worm(x,y,bodyPart)
sync
}

function move_worm(x,y,bodyPart)
snake(1,1)=x
snake(1,2)=y
For i=bodyPart+1 to 2
snake(i,1)=snake(i-1,1)
snake(i,2)=snake(i-1,2)
Position object i,snake(i,1),snake(i,2)
next i
endfunction


I'm not sure if this will work, and it will require editing (because I think I included a bit of Java in here) but I think this might give you a general idea of how to do what it is you want. Enjoy!

"Everyone has a photographic memory . . . some just don't have film."

Login to post a reply

Server time is: 2024-04-25 05:47:22
Your offset time is: 2024-04-25 05:47:22