Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- #include "helpers.h"
- #include <time.h>
- void pause(SDL_Rect pos, SDL_Surface* ecran)
- {
- int continuer = 1;
- SDL_Event event;
- while (continuer)
- {
- SDL_WaitEvent(&event);
- switch(event.type)
- {
- case SDL_QUIT:
- continuer = 0;
- default:
- pos.y += 10;
- generateSprite(pos, randomSprite, ecran);
- if(pos.y < 400)
- {
- pos.y = 0;
- randomSprite() = generateSprite();
- srand(time(NULL));
- int absrand = rand()%550;
- pos.x = absrand;
- }
- }
- }
- }
- int randomSprite()
- {
- srand(time(NULL));
- int rtn = rand()%5;
- return rtn;
- }
- void generateSprite(SDL_Rect pos1, int spriteType, SDL_Surface* ecran)
- {
- SDL_Surface *logo_Evolukid1 = NULL;
- SDL_Surface *logo_Evolukid2 = NULL;
- SDL_Surface *logo_Evolukid3 = NULL;
- SDL_Surface *logo_Evolukid4 = NULL;
- logo_Evolukid1 = SDL_LoadBMP("imageCool.bmp");
- logo_Evolukid2 = SDL_LoadBMP("imageCool.bmp");
- logo_Evolukid3 = SDL_LoadBMP("imageCool.bmp");
- logo_Evolukid4 = SDL_LoadBMP("imageCool.bmp");
- SDL_Rect pos2;
- SDL_Rect pos3;
- SDL_Rect pos4;
- switch(spriteType)
- {
- case LD:
- // Dessine une L Droit
- pos2.x = pos1.x;
- pos2.y = pos1.y + 60;
- pos3.x = pos1.x;
- pos3.y = pos1.y + 120;
- pos4.x = pos1.x + 60;
- pos4.y = pos1.y + 120;
- break;
- case BARRE:
- // Dessine une barre
- pos2.x = pos1.x;
- pos2.y = pos1.y + 60;
- pos3.x = pos1.x;
- pos3.y = pos1.y + 120;
- pos4.x = pos1.x;
- pos4.y = pos1.y + 120;
- break;
- case TD:
- // Dessine un T droit
- pos2.x = pos1.x + 60;
- pos2.y = pos1.y;
- pos3.x = pos1.x + 120;
- pos3.y = pos1.y;
- pos4.x = pos1.x + 60;
- pos4.y = pos1.y + 60;
- break;
- case CARRE:
- // Dessine un carre
- pos2.x = pos1.x;
- pos2.y = pos1.y + 60;
- pos3.x = pos1.x;
- pos3.y = pos1.y + 120;
- pos4.x = pos1.x + 60;
- pos4.y = pos1.y + 120;
- break;
- case LI:
- // Dessine un L inverse
- pos2.x = pos1.x;
- pos2.y = pos1.y + 60;
- pos3.x = pos1.x;
- pos3.y = pos1.y + 120;
- pos4.x = pos1.x + 60;
- pos4.y = pos1.y + 120;
- break;
- default:
- break;
- }
- SDL_BlitSurface(logo_Evolukid1, NULL, ecran, &pos1);
- SDL_BlitSurface(logo_Evolukid2, NULL, ecran, &pos2);
- SDL_BlitSurface(logo_Evolukid3, NULL, ecran, &pos3);
- SDL_BlitSurface(logo_Evolukid4, NULL, ecran, &pos4);
- SDL_Flip(ecran);
- SDL_Delay(100);
- SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
- SDL_Flip(ecran);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement