Bonjour,je programme en c++ et j'ai un pb voila mon code:
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
void pause();
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL, *gg = NULL, *pp = NULL, *jj = NULL;
SDL_Rect positiongg, positionpp, positionjj;
SDL_Event event;
int continuer = 1;
int i=0;
positionjj.x = 1;
positionjj.y = 1;
jj = SDL_LoadBMP("mur.bmp");
SDL_SetColorKey(jj, SDL_SRCCOLORKEY, SDL_MapRGB(jj->format, 0, 0, 255));
SDL_BlitSurface(jj, NULL, ecran, &positionjj);
SDL_Surface ** Lesimages[]={ &gg, &pp, NULL};
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
SDL_WM_SetCaption("mon premier jeu", NULL);
gg = SDL_LoadBMP("dbz1.bmp");
SDL_SetColorKey(gg, SDL_SRCCOLORKEY, SDL_MapRGB(gg->format, 0, 0, 255));
pp = SDL_LoadBMP("dbz2.bmp");
SDL_SetColorKey(pp, SDL_SRCCOLORKEY, SDL_MapRGB(pp->format, 0, 0, 255));
/* On centre Zozor à l'écran */
positiongg.x = ecran->w / 2 - gg->w / 2;
positiongg.y = ecran->h / 2 - gg->h / 2;
positionpp.x = ecran->w / 2 - pp->w / 2;
positionpp.y = ecran->h / 2 - pp->h / 2;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_RIGHT: // Flèche droite
positiongg.x++;/* je pense que tout se passe ici*/
break;
case SDLK_o: //touche o
i++;
if(i>1)/*Si i est plus grand que 1 (donc qu'il n'a pas d'image allouée puisque le tableau va jusque 2 images(0, 1)), mettre i à 0, donc à la 1ère image*/
{
i=0;
}
positiongg.x++;
break;
}
break;
}
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
SDL_BlitSurface(*Lesimages[i], NULL, ecran, &positiongg); /* On place la nouvelle image */
SDL_Flip(ecran); /* On met à jour l'affichage */
}
pause();
SDL_FreeSurface(jj);
SDL_FreeSurface(gg);
SDL_FreeSurface(pp);
SDL_Quit();
return EXIT_SUCCESS;
}
void pause()
{
int continuer = 1;
SDL_Event event;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
}
}
}
et l'image "mur" ne s'affiche pas est ce normale?
sinon aidez moi a l'afficher svp.
Merci.
Lucbu