SDL porbleme

fahdovski Messages postés 4 Date d'inscription vendredi 7 mars 2008 Statut Membre Dernière intervention 4 avril 2008 - 8 mars 2008 à 16:05
manrugby Messages postés 2 Date d'inscription lundi 21 juillet 2008 Statut Membre Dernière intervention 22 juillet 2008 - 22 juil. 2008 à 17:24
IL Y'A EXECUTION MAIS LE PC PLANTE IL DEVIENT TRES LENT, MAIS POURQUOI??????
jE TRAVAILLE SUR CODE::BLOCKS SOUS LINUX
AVANT CA MARCHAIS IMPEC QUESQUI C'EST PASSE DANS L'ORDI???

#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>

main(int argc,char *argv[])
{//INITIALISER
    SDL_Surface *ecran=NULL,*background=NULL,*image=NULL;
int go=1;SDL_Event event;

SDL_Rect posimage, posbackground;
posbackground.x=0;
posbackground.y=0;
posimage.x=200;
posimage.y=200;

    if (SDL_INIT_VIDEO==-1)
    return (EXIT_FAILURE);
//CREE L'ECRAN
   ecran= SDL_SetVideoMode(800,600,32,SDL_HWSURFACE | SDL_DOUBLEBUF);
//ECRIRE DU TEXTE SUR LA FENETRE
    SDL_WM_SetCaption("TeTrIs",NULL);
    //LOADIND PICTURES
   background= IMG_Load("/home/fahd/Pictures/Setsuna.npg");
   SDL_BlitSurface(background,NULL,ecran,&posbackground);
   image=IMG_Load("/home/fahd/Documents/SDL TUTO/tux.bmp");
   SDL_SetColorKey(image,SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 255, 255, 255));
   SDL_BlitSurface(image,NULL,ecran,&posimage);

    SDL_Flip(ecran);

    while(go==1)
  {  SDL_WaitEvent(&event);
    switch(event.type)
    {
        case (SDL_QUIT): go=0;break;
        case (SDLK_ESCAPE):go=0;break;

        {
            case (SDL_BUTTON_LEFT):
            posimage.y=event.button.y;break;
            posimage.x=event.button.x; break;
          
        }
        case (SDL_KEYDOWN):

        switch(event.key.keysym.sym)
        {
            case SDLK_UP: posimage.y-=5;break;
            case SDLK_DOWN: posimage.y+=5;break;
            case SDLK_RIGHT: posimage.x+=5;break;
            case SDLK_LEFT: posimage.x-=5;break;
            case SDLK_ESCAPE: go=0;break;
        }
    }
SDL_ConvertSurface(ecran, background, 0);
    SDL_BlitSurface(image,NULL,ecran,&posimage);
  SDL_Flip(ecran);

}

     SDL_FreeSurface(background);
     SDL_FreeSurface(image);
     SDL_Quit();
     return EXIT_SUCCESS;
}

2 réponses

insatien007 Messages postés 1 Date d'inscription jeudi 6 mars 2008 Statut Membre Dernière intervention 19 mars 2008
19 mars 2008 à 00:10
fahd on doit remplir l'image par pixel !!
un tableau d'entier
1== bleu
2==jaune
0
manrugby Messages postés 2 Date d'inscription lundi 21 juillet 2008 Statut Membre Dernière intervention 22 juillet 2008
22 juil. 2008 à 17:24
lol ta une drole de façon de coder
0
Rejoignez-nous