Sprite sheet animatiion question

Hi,
I have three sprite sheets (image 1,2,and 3) one and two are 21 frames long, but three is 120 frames long. I have it so ( my boxing animation) if " health < 1 "
that it will play the 120 frames sheet, BUT, it only plays 21 frames of it. How would I get it to play the whole 120 frames?

Thx


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include <SDL/SDL_mixer.h>
        #include "rects.h"
        #include <ctime>
        #include <cstdlib>
        #include <windows.h>
        #include <iostream>

        	using namespace std;

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        int main( int argc, char* args[] )
        {
        	SDL_Init(SDL_INIT_EVERYTHING);
        	SDL_Surface* screen,*image, *image2,*image3;
        	Mix_Music* music , *music2, *music3 ;
        	Mix_OpenAudio(22050,MIX_DEFAULT_FORMAT,2,4096);
        	music=Mix_LoadMUS("punch.wav");
        	music2=Mix_LoadMUS("block.wav");
        	music3=Mix_LoadMUS("victory.wav");
        	screen=SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
        	bool running=true;
        	const int FPS=20;
        	Uint32 start;
        	SDL_Rect rect;
        	int frame=0;
        	rect.x=100;
        	rect.y=100;
        	rect.w=50;
        	rect.h=50;
        	Uint32 color=SDL_MapRGB(screen->format,0x00,0x00,0x00);
        	Uint32 color2=SDL_MapRGB(screen->format,0xff,0xff,0xff);
        	image=SDL_DisplayFormat(SDL_LoadBMP("punch.bmp"));
        	image2=SDL_DisplayFormat(SDL_LoadBMP("block.bmp"));
        	image3=SDL_DisplayFormat(SDL_LoadBMP("victory.bmp") );
        	SDL_Rect rects[21];
        	setrects(rects);
        	SDL_SetColorKey(image,SDL_SRCCOLORKEY,SDL_MapRGB(s creen->format,0x00,0xff,0xff));




        	int health = 60;
        	srand((unsigned)time(NULL));
        	int random = rand() % 3+ 1 ;
        	while(running)
        	{

        		SDL_WM_SetCaption("Prototype!!",NULL);
        		start=SDL_GetTicks();
        		SDL_Event event;
        		while(SDL_PollEvent(&event))
        		{

        			switch(event.type)
        			{
        			case SDL_QUIT:
        				running=false;
        				break;
        			}
        		}



        		SDL_Rect rect;
        		rect.x=0;
        		rect.y=0;

        		/////////////////////////////////////////////////////////////////////////////////////////////////////


        		switch (random)
        		{
        		case 1:
        			SDL_BlitSurface(image, &rects[frame], screen, &rect);
             		break;

        		case 2:

        			SDL_BlitSurface(image2,&rects[frame],screen,&rect);
              		break;

        		case 3:
                                if( health < 1)
                                 {    
        			SDL_BlitSurface(image3,&rects[frame],screen,&rect);

                                     }
        			break;

        		}




        		////////////////////////////////////////////////////////////////////////////////////////////////////////



        		SDL_Flip(screen);
        		frame++;
        		if(frame==21)
        		{

        			frame=0;
        			srand((unsigned)time(NULL));
        			random=rand()%3+1;
        			Mix_HaltMusic();
        			if(random==1)
        			{
        				Mix_PlayMusic(music,0);
        				health--;
        			}
        			else if(random==2)
        			{
        				Mix_PlayMusic(music2,0);
        				health--;
        			}
        			else if(random==3)
        			{
        				Mix_PlayMusic(music3,0);
        				health--;
        			}

        		}

        		if(1000/FPS>SDL_GetTicks()-start )
        			SDL_Delay(1000/FPS-(SDL_GetTicks()-start));

        		if(health < 0 )
        			running = false;


        	} // end while()


        	Mix_FreeMusic(music);
        	Mix_FreeMusic(music2);
        	Mix_FreeMusic(music3);

        	Mix_CloseAudio();
        	SDL_FreeSurface(image);
        	SDL_FreeSurface(image2);
        	SDL_FreeSurface(image3);
        	SDL_Quit();
        	return 0;


        } // end main() 
Topic archived. No new replies allowed.