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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
| #include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
void pause();
void clignotement ();
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL, *aries = NULL, *jauge = NULL, *depart = NULL, *texte = NULL, *start = NULL;
long *clignote = 0;
long tableau [10];
SDL_Rect positionAries;
SDL_Rect positionJauge;
SDL_Rect positionDepart;
SDL_Rect positionTexte;
SDL_Rect positionStart;
SDL_Event event;
int continuer = 1, intro = 1;
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
SDL_WM_SetCaption("Mon jeu en cour de developement...", NULL);
while (intro == 1)
{
/* Chargement du fond de presentation */
depart = SDL_LoadBMP("presentation.bmp");
SDL_SetColorKey(depart, SDL_SRCCOLORKEY, SDL_MapRGB(depart->format, 0, 255, 0));
/* Chargement du texte de presentation */
depart = SDL_LoadBMP("texte.bmp");
SDL_SetColorKey(texte, SDL_SRCCOLORKEY, SDL_MapRGB(texte->format, 0, 255, 0));
/* Chargement du start de presentation */
depart = SDL_LoadBMP("start.bmp");
SDL_SetColorKey(start, SDL_SRCCOLORKEY, SDL_MapRGB(start->format, 0, 255, 0));
positionDepart.x = 0;
positionDepart.y = 0;
positionTexte.x = 543;
positionTexte.y = 0;
positionStart.x = 250;
positionStart.y = 400;
SDL_SetAlpha(start, SDL_SRCALPHA, 0);
SDL_SetAlpha = clignotement;
SDL_BlitSurface(depart, NULL, ecran, &positionDepart); /* On place le depart à sa nouvelle position */
SDL_BlitSurface(texte, NULL, ecran, &positionTexte); /* On place le texte à sa nouvelle position */
SDL_BlitSurface(start, NULL, ecran, &positionStart); /* On place start à sa nouvelle position */
if (intro == 1)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_KP_ENTER :
intro = 0 ;
break;
}
break;
default :
intro = 1 ;
break;
}
}
}
pause();
SDL_FreeSurface(depart);
SDL_FreeSurface(texte);
SDL_FreeSurface(start);
/* Chargement de Aries */
aries = SDL_LoadBMP("ariescombatant.bmp");
SDL_SetColorKey(aries, SDL_SRCCOLORKEY, SDL_MapRGB(aries->format, 0, 255, 0));
/* Chargement de notre Jauge */
jauge = SDL_LoadBMP("jauge_baton.bmp");
SDL_SetColorKey(jauge, SDL_SRCCOLORKEY, SDL_MapRGB(jauge->format, 255, 0, 0));
/* On centre Aries à l'écran */
positionAries.x = ecran->w / 2 - aries->w / 2;
positionAries.y = ecran->h / 2 - aries->h / 2;
/* On cadre notre Jauge à l'écran */
positionJauge.x = 0;
positionJauge.y = 0;
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_UP: // Flèche haut
positionAries.y-=10;
break;
case SDLK_DOWN: // Flèche bas
positionAries.y+=10;
break;
case SDLK_RIGHT: // Flèche droite
positionAries.x+=10;
break;
case SDLK_LEFT: // Flèche gauche
positionAries.x-=10;
break;
}
break;
}
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0)); /* On efface l'écran */
SDL_BlitSurface(aries, NULL, ecran, &positionAries); /* On place Aries à sa nouvelle position */
SDL_BlitSurface(jauge, NULL, ecran, &positionJauge); /* On place la jauge à sa nouvelle position */
SDL_Flip(ecran); /* On met à jour l'affichage */
}
SDL_Flip(ecran); /* On met à jour l'affichage */
SDL_FreeSurface(aries);
SDL_FreeSurface(jauge);
pause () ;
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;
break;
}
}
}
void clignotement (long *clignote) // On fait clignoter notre image.
{
for (clignote = 0 ;clignote <= 0; clignote++)
{
long tableau [10];
tableau[0] = 0;
tableau[1] = 70;
tableau[2] = 128;
tableau[3] = 255;
tableau[4] = 255;
tableau[5] = 255;
tableau[6] = 255;
tableau[7] = 128;
tableau[8] = 70;
tableau[9] = 0;
}
} |
Partager