Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (754) Games in Android Showcase (229) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Snake (2nd part): Smooth-Moving  (Read 2692 times) 0 Members and 1 Guest are viewing this topic.
daGrevis

Senior Newbie

 « Posted 2011-05-16 11:00:10 »

Hey there!

I'm still workin' on my Snake's game (latest version)! I think out that I want to jump to Slick library and, by the way, I have new game's loop as well!

My next goal is to make the snake to move in constant time from A to B (let's say that length from A to B is 20 pixels), but player needs to see the snake actually moving pixel by pixel. It's like smooth-moving! SPEED is contant of snake's speed. I need to somehow implement it all... old snake, Slick and/or new loop. Any ideas? Examples, links to tutorials, anything? I know that we can figure it out!

God is Real, unless declared Integer.
kieve

Senior Newbie

I am Awesome.

 « Reply #1 - Posted 2011-05-16 15:37:01 »

If i remember correctly, your position updates UNIT distance every time frame. If you kept two variables, one for the unit it should move to and another for individual pixels. The speed equation (general) = UNIT / time so to move at that speed but one pixel at a time it would look like:
1/x = UNIT/time
x = time/unit
There for you should move render the snake 1 pixel every update time witch would be:  (time / unit distance).

Please correct any errors I may have created here, I like to learn from those mistakes.

import universe.characteristics.Awesome
class kieve extends Awesome{
public kieve(){
beAwesome();
}
public void beAwesome(){
while(true)awesomeness++;
}
}