Ça ne marche toujours pas, mais comment au juste comparer le 2e argument avec / s , avec strcmp ou if(arg[1] ! = ´/s´) ou if(arg[1] ! = " /s") ou comment?
Voici mon programme si tu veux le compiler et le tester(voici l´image http://img11.exs.cx/my.php?loc=img11&image=32sprites3uk.png et changela en bmp):
- include < stdio.h>
- include < stdlib.h>
- include < SDL/SDL.h>
SDL_Surface *screen;
class sprite
{
public:
int nombre; / /chiffre à afficher
int vitesse; / / vitesse
int next; / /temps du prochain changement
static int total; / /nombre de chifrre
static SDL_Surface *ima;
SDL_Rect r,d;
sprite(int time); / /constructeur
void actusprite(int &) / / regarde si on doit chager d´étape
{
if(time > next)
{
next= time +vitesse;
nombre++;
if(nombre>10)
nombre=0;
r.x=nombre*32;
}
}
};
int sprite::total=0; / / déclare les membre static de sprite
SDL_Surface *sprite::ima =SDL_CreateRGBSurface(SDL_HWSURFACE, 800, 600, 32, 0, 0, 0, 0);
sprite::sprite(int time=SDL_GetTicks())
{
int temp=0;
nombre=0; / /organise chaque sprite
vitesse=(rand()%2000)+200;
next=time;
r.x=nombre*32; / /surface de départ
r.y=0;
r.w=32;
r.h=32;
d.x = ( total%25)*32; / /surface d´arriver
d.y=(total/25)*32;
d.h=32;
d.w=32;
total++;
}
void initsdl() / /initialise la sdl
{
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)<0)
{
printf("SDL can´t init %s" , SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
SDL_ShowCursor(0);
screen
=SDL_SetVideoMode(800,600,32,SDL_FULLSCREEN|SDL_HW
SURFACE|SDL_DOUBLEBUF);
if(screen==NULL)
{
printf("Can´t set video mode %s", SDL_GetError());
exit(2);
}
sprite::ima= SDL_LoadBMP("32sprites.bmp");
}
int main(int argc, char* argv[])
{
if(strcmp(argv[1],"/s") ! =0) exit(0);
SDL_Event event;
bool done =true;
initsdl();
int i;
srand(SDL_GetTicks()); / /nombre aléatoire
int time;
sprite chiffre[476];// tout les nombre
while(done==true)
{
time=SDL_GetTicks(); / /réorganise les sprite à la bonne étape
for(i=0;i<476;i++)
{
chiffre[i].actusprite(time);
}
SDL_PollEvent(&); / /attend une touche
if(event.type==SDL_KEYDOWN ) break;
for(i=0;i<476;i++)
{
SDL_BlitSurface(sprite::ima, &[i].r, screen , &[i].d);
}
SDL_Flip(screen);
}
return 0;
}