Hi.
I have a few questions about 2d games (in which you see the game straight down from the sky (from top)).

The first question is about movement. Ok, if i want to move a player on a background which does not consist of one solid color only - which is mostly the case - what will i have to do to achieve this movement? games which have no animations, just movement, usually have a "cell or grid" system, or however you call that. the game consists of several rectangles, which all have the same size. each sprite usually has the size of such a rectangle or a multiple of such a rectangle. so to make a player move, you can just do this:
1) save the background of the rectangle into which the player will step.
2) move the player into this rectangle
3) restore the background of the rectangle in which the player has been before movement

But how do i do this if i use animations and not a grid system?
For example if the animation consist of 2 states:
1) move one leg into the moving direction
2) stand still again:

0 0
|--- |---
| |
|\ ||
| \ ||
movement standing still again

Would i have to do this somehow like this:
1)Save background of next animation rectanle
2)Move player into this rectangle and show animation state 1 (movement)
3)restore background of the rectangle in which the player has been before movement
3)wait a bit
4)save background of next animation rectangle
5)move player into this rectangle and show animation state 2 (standing still again)
6) restore background of animation 1 rectangle


And now another question about sword animation and determining a hit:
Ok, assume there is a player standing still. now he swings his sword. the sword swing will go through a few animations swinging from top to bottom. will i have to do a collision detection with the sword rectangle of each animation and all monster and wall rectangles and check if it "hits" a monster or a wall? wouldn't that be a bit too much work for such a quick animation?
A small example:
The sword animation could look like this:

\---->
0 / 0 -|----> 0 0
|/ |/ |---|----> |\
| | | | |---->
|\ |\ |\ |\
| \ | \ | \ | \

Would i now have to do collision detection checks in all 4 animation states with the sword and all wall and monster rectangles?

And another small question about the sword swinging animation itself:
These 4 swinging animations have to be 4 different bitmaps, right? or is there another possibility to do this without having to draw the guy with the sword 4 times only in other swinging states?
And how do i do this animation? Somehow like this:
1)save background of a rectangle in which all 4 animations states will take place
2)draw animation state 1 + col. detection
3)wait
4)restore background
5)draw animation state 2 + col. detection
6)wait
7)restore background
8)draw animation state 3 + col. detection
9)wait
10)restore background
11)draw animation state 4 + col. detection

If i did it like this, it would be again a bit too much work for such a cheap animation, right? is there a faster/easier way?


That's all. Hope someone can help me.

Thanks.
Posted on 2001-12-17 08:07:34 by darester
ooops. the animation ascii pictures didn't come out like they were supposed to. hope you still understand what i'm talking about...
Posted on 2001-12-17 08:08:51 by darester
The easiest way is to have a bunch of bitmaps and create the scene at each frame. Just render the scene in layers. Usually there is a bottom layer of tiles that are just pasted to a buffer, then masks are used to paste sprites onto those graphics. You mask out an area for the sprite, then paste it over. It goes pretty fast, too. 2D is awesome, but requires a good pixel artist - that is why everyone is moving to 3D - good pixel artist are worth their weight in gold!
Posted on 2001-12-17 12:35:45 by bitRAKE
thanks for your reply. i think i got it :p
Posted on 2001-12-18 11:38:27 by darester
You could associate a bitmap with all the possible orientation of the player, and use a variable to store the current frame of the animation. When the player moves, increment the variable and use it to calculate the offset in the bitmap associated to the direction of the move.

To display the sword animation, you could consider the sword as a separate element, with 2 coordinates (x, y), a state, and a frame. When the player uses the sword, update the coordinates of the sword and the frame. To make collision detection faster, assume the sword is always a single line, no matter the frame.

I hope you understand. Good luck
Posted on 2001-12-18 14:52:20 by Dr. Manhattan