Walking in 2d game

Posted By: Varen

Walking in 2d game - 08/07/09 20:13

Hey, im making 2d multiplayer game and i have some questions for u, masters of programming ^^:
1) how should i make an animated character walking to a target on the map by clicking with the mouse? It should have different animations for walking right, left, up and down. It should be animated standing as well, kinda animation of breathing:

2) how should the map be created, as panel? And how to make character stick to the center of the screen (i mean when he is walking, the world "moves")? The character can go to every direction

I know there are many tutorials but most of them are about 3d games and animation of models, not 2d characters
Posted By: Scorpion

Re: Walking in 2d game - 08/08/09 18:13

I am not sure if it's the best to start with mp, because it's pretty complicated and with panels you can't use the helper functions gs offers you to make it easier.

Imo it would be the best, if you create for a player entity a struct, which holds all information like position, health, name, etc. and a pointer to a panel.

for the animation of the character you should look into the window element of panels.

the tricky part about 2d games is, that you have to code your own 'camera'. All you need is a vector, that stores the cams positions (top left corner works always fine) and for every element in a scene a vector that stores its absolute (=world) coordinates.
If you now as example move the camera 10px to the right, everything on screen is getting shifted 10px to the left. so to get the screen position of the panels, you have to take their world coordinates and subtract the cameras position.

I hope I could clear things up a little bit
Scorpion
© 2024 lite-C Forums