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
| #define TEMPS_TIR 1000
#define HAUTEUR_ECRAN 480
#define LARGEUR_ECRAN 640
int main(int argc, char *argv[])
{
// initialisation des variables
// chargement des autres surfaces dont la surface *Joueur
tir = SDL_CreateRGBSurface (SDL_HWSURFACE,200, 20, 32, 0, 0, 0, 0);
SDL_FillRect (tir, NULL, SDL_MapRGB(ecran->format, 120, 120, 120));
posTir.x = posJoueur.x + Joueur->w;
posTir.y = posJoueur.y + Joueur->h/8;
while(!in.key[SDLK_ESCAPE]) //tant que toucheEnfoncée != echap
{
tempsActuel = SDL_GetTicks ();
if(in.key[SDLK_SPACE])
tempsInitial = tempsActuel;
if (tempsActuel - tempsInitial < TEMPS_TIR)
{SDL_BlitSurface (tir, NULL, ecran, &posTir);SDL_Flip(ecran);}
SDL_FillRect (ecran, NULL, SDL_MapRGB(ecran->format, 20, 50, 120));
SDL_BlitSurface (carre, NULL, ecran, &posCarre);
SDL_BlitSurface (Joueur, NULL, ecran, &posJoueur);
SDL_Flip(ecran);// affichage de tout le bordel
} |
Partager