Puntoinfinito

SDL bullet engine

Jan 30th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. /* Blit each bullet with her position. It not starts until the user not press space for first time */
  2. SDL_Rect posicion2;
  3.         for (int i = 0;i < disparos;i++) {
  4.             posicion2.x = posDisparo[i].x;
  5.             posicion2.y = posDisparo[i].y;
  6.             SDL_BlitSurface(disparo, NULL, screen, &posicion2);
  7.                    
  8.         }
  9.  
  10.  
  11. //Looking succes
  12. while (SDL_PollEvent(&suceso)) {
  13.             if (suceso.type == SDL_QUIT) {
  14.                 terminado = 1;
  15.             }
  16.             if (suceso.type == SDL_KEYDOWN) {
  17.                 if (suceso.key.keysym.sym == SDLK_ESCAPE) {
  18.                     terminado = 1;
  19.                 }
  20.             }
  21.         }
  22.  
  23. /* Space = add one bullet and the position of it with one array that are controllated for the variable "disparos" */
  24. if (teclas[SDLK_SPACE]) {
  25.            
  26.             disparos++;
  27.             posDisparo[disparos].x = xNave + 25;
  28.             posDisparo[disparos].y = yNave + 20;
  29.         }
  30.  
  31. //-1 pixel each bullet
  32.         for (int i = 0;i < disparos;i++) {
  33.             posDisparo[i].y -= 1;
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment