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.

Newcomers DBPro Corner / Smth like a Snake game

Author
Message
DynamicLink
11
Years of Service
User Offline
Joined: 26th May 2013
Location:
Posted: 31st Jul 2013 16:09 Edited at: 31st Jul 2013 19:10
I'm trying to code something like a snake game and i can't work around a display issue. I'll post what i have done so far. The idea is that from times to times, the body spheres are moving abruptly, taking away the program's smoothness.
chafari
Valued Member
18
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 31st Jul 2013 19:51 Edited at: 31st Jul 2013 20:00
What do you mean?
You could force to just four direction up down left right

This example was for a 20lines code...take a look.



I'm not a grumpy grandpa
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 15th Aug 2013 07:45 Edited at: 15th Aug 2013 07:47
Are you referring to how the trailing balls jitter when you perform a hard turn? If so, I do not think it is a display issue.

I believe this has to do with how you have each ball point at the one in front of it and move if there is no collision. When the leading ball makes a turn, the trailing ball has to wait for it to move away before it can occupy its space. Thus, the trailing ball stops and waits for the leading ball to finish its turn.

To resolve this, you could keep an array of the last, say, 100 positions occupied by the leading ball (the number of positions will depend on how long you allow the snake tail to become), and then have each of the trailing balls move through those positions in turn. This would probably work but it could get a little complicated.

Alternately you could take chafari's approach and create a ball at the leading ball's position and delete the ball at the end of the trail each loop, creating the illusion of a trail. This seems like the easier option. Depending on how fast your snake moves you could have some of the balls overlap though (ex. leading ball is size 10, a trailing ball spawns at its location, the leading ball only moves 2, now part of the leading ball is still inside the trailing ball).

There is probably some other super simple solution that I'm missing right now so keep an ear open for other replies

Hmm. It's been a while .
DynamicLink
11
Years of Service
User Offline
Joined: 26th May 2013
Location:
Posted: 28th Aug 2013 23:28
thanks guys

@chafari: I tried to do a smoother and more modern version of snake. As I don't know how to create/work with characters created with other software, i made the snake up from a bunch of spheres.
@Squares: recently i've been thinking of changing the order the spheres move meaning that i should try to move them starting from the last one to the first, so that i don't lose the position of the frame. i'll come with an update if this method works.

Login to post a reply

Server time is: 2024-11-23 09:56:39
Your offset time is: 2024-11-23 09:56:39