I would like to learn how to manage sprite movement more efficiently.
There are a couple of things that I'm solving using a "brute force" approach and I wonder if there's a more "PSX-oriented" way of doing this.
I'll try to keep it short :-)
Basically what I would like to do is the following:
1_ Automatically animate a sprite according to the number of frames available
2_ Correct timing of the frames animation
3_ Tips in order to minimize calculations
(1) In order to "animate" a sprite I have to change GsSPRITE.u GsSPRITE.v coordinates relative to the TIM file. Currently I have a struct to manage an item on screen:
Code: Select all
struct MyHero
{
GsIMAGE img;
GsSPRITE sprt;
...
};
I want to automatically invoke a animateSprite(GsSPRITE sprite) method that calculates the next frame to use.
I could add a "frame_index" property in the struct and keep track of the current frame; then proceed like this to calculate the offset of the TIM file:
Code: Select all
(TIM width / num_frames) * frame_index++
(2) How do I correctly synchronize the sprite animation in order to prevent a visual flickering?
(3) What is an efficient way to organize sprite frames in the TIM file in order to minimize these calculations?
Examples: the first row/column of the TIM file frame for basic sprite movement, the second one is for explosion animation, and so on... suggestions?
Thanks