Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char *argv[])
- {
- int gameloop = 1;
- while (gameloop)
- {
- SDL_Event move;
- SDL_PollEvent(&move);
- switch(move.type) // Test du type d'évènement
- {
- case SDL_QUIT: // Si c'est un évènement de type "Quitter"
- gameloop = 0;
- break;
- case SDL_KEYDOWN:
- switch (move.key.keysym.sym)
- {
- case SDLK_ESCAPE:
- gameloop = 0;
- break;
- case SDLK_SPACE:
- break;
- }
- }
- SDL_Surface *ecran = NULL, *dauphin = NULL, *background = NULL;
- SDL_Rect position_dauphin, position_background;
- position_dauphin.x = 50;
- position_dauphin.y = 150;
- position_background;
- position_background.x = 0;
- position_background.y = 0;
- SDL_Init(SDL_INIT_VIDEO); // Initialisation de la SDL
- SDL_WM_SetCaption("Blue Ocean ~prototype~", NULL);
- ecran = SDL_SetVideoMode(800, 600, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); // On tente d'ouvrir une fenêtre
- if (ecran == NULL) // Si l'ouverture a échoué, on écrit l'erreur et on arrête
- {
- fprintf(stderr, "Impossible de charger le mode vidéo : %s\n", SDL_GetError());
- exit(EXIT_FAILURE);
- }
- SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 30, 145, 183));
- background = IMG_Load("background.png");
- //SDL_SetColorKey(zozor, SDL_SRCCOLORKEY, SDL_MapRGB(dauphin->format, 255, 0, 0));
- // Utilisez SDL_SRCCOLORKEY pour activer la transparence, 0 pour la désactiver.
- SDL_BlitSurface(background, NULL, ecran, &position_background);
- dauphin = IMG_Load("dauphin.png");
- SDL_SetAlpha(dauphin, SDL_SRCALPHA, 200);
- SDL_BlitSurface(dauphin, NULL, ecran, &position_dauphin);
- SDL_Flip(ecran); /* Mise à jour de l'écran */
- SDL_FreeSurface(dauphin); /* On libère la surface */
- SDL_FreeSurface(background);
- SDL_Quit(); // Arrêt de la SDL
- return EXIT_SUCCESS; // Fermeture du programme
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement