Making an character move (walk)

Started by
3 comments, last by prof_89 17 years, 2 months ago
Hi again, we have gotten a bit further in our game now. As you might see if you test the game you see that if you move, you just "poff" and you are at your next position, we would like to make the character actually GO to the next tile instead of just teleport himself there... how could we do that ? http://www.freewebs.com/prof_89/appletgame/spel.html
Advertisement
due to the discrete nature of computer logic, the display of all motions consits of a series of static scenes
it is the human mind who interprets two different scenes as motion

sometimes though, unimaginitve minds choose not to 'see' that the object on screen has moved; and sees 'teleportation' instead.

we can help people like that, by using smaller steps (with less change) from one scene to the next.
in other words, increase your framerate.
ok, looking at your game (same AP as above btw)
I'm guessing that you're game is Tile Based
and to whenever the user presses a control, you simply redraw the character's sprite on top of a different tile

personally, i dont think its that much a problem, considering this is an browser applet, and there is a great precedent for this kind of motion to pass as 'motion' to most gamers of the browser applet genre

but if you really want it to look smoother, you're going to have to rework your rendering methods to allow for sprites that do not align with the Tiles.
Then when the player moves, rather than simply redraw him on the next tile, draw him 1/4 of the way between them, then 1/2 way, then 3/4s the distance, finally ending with a final redraw in the new position. Of course, more inbetween positions will look smoother. But you get the key concept.
What I implemented in my latest project (and what is done in most similar games from what I know) is some (most popular A*) path finding algorithm.

Once the path to the destination is found I made my sprite move by 4 pixels every fame (that lasts around 0.1 sec) from one square to another (according to the path found) till it reaches its goal.

Also, my sprite image changes every frame (legs and arms are moving) for even better movement animation look.

This takes quite a bit time to organize and implement things but the final effects look good.
ok, thanks for the answers, i will try it later on..

and it is tilebased yes

This topic is closed to new replies.

Advertisement