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
| #include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include "user.h"
int main(int argc, char *argv[])
{
SDL_Surface *ecran = NULL, *texte = NULL, *fond = NULL, *texte2 = NULL, *texte3 = NULL, *rectangle = NULL;
rectangle = SDL_CreateRGBSurface(SDL_HWSURFACE, 200, 100, 32, 0, 0, 0, 0);
SDL_Rect position;
SDL_Event event;
TTF_Font *police = NULL, *police2= NULL;
SDL_Color couleurMov = {111, 32, 211};
SDL_Color couleurStart = {248, 248, 25};
SDL_Color couleurNoire = {0,0,0};
int continuer = 1;
putenv("SDL_VIDEO_WINDOW_POS=center");
SDL_Init(SDL_INIT_VIDEO);
TTF_Init();
ecran = SDL_SetVideoMode(760, 532, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_WM_SetCaption("BOMBERMAN", NULL);
fond = SDL_LoadBMP("bomber.bmp");
/* Chargement de la police */
police2 = TTF_OpenFont("Andrew.ttf", 20);
police = TTF_OpenFont("BURNSTOW.ttf", 100);
/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
texte = TTF_RenderText_Blended(police, "BOMBERMAN", couleurMov);
texte2 = TTF_RenderText_Blended(police2, "Press any key to start", couleurStart);
/*texte3 = TTF_RenderText_Blended(police2, "Press any key to start", couleurNoire);*/
/* SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255));*/
position.x = 0;
position.y = 0;
SDL_BlitSurface(fond, NULL, ecran, &position); /* Blit du fond */
SDL_Flip(ecran);
position.x = 120; /* position du texte Bomberman */
position.y = 350;
SDL_BlitSurface(texte, NULL, ecran, &position); /* Blit du texte par-dessus */
SDL_FillRect(rectangle, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
/* _sleep(400);*/
SDL_Flip(ecran);
/* _sleep(1000);*/
position.x = 285; /* position de press any key */
position.y = 470;
SDL_BlitSurface(texte2, NULL, ecran, &position); /* Blit du texte par-dessus */
SDL_Flip(ecran);
while (continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN: /* Si appui d'une touche */
/*user(ecran);*/
break;
}
}
TTF_CloseFont(police);
TTF_CloseFont(police2);
TTF_Quit();
SDL_FreeSurface(texte);
SDL_FreeSurface(rectangle);
SDL_Quit();
return EXIT_SUCCESS;
} |
Partager