diff options
Diffstat (limited to 'Juego.py')
-rwxr-xr-x | Juego.py | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -8,6 +8,7 @@ import pygame from pygame.locals import * from Jugador import Jugador +from Nave import Bala Ancho = 1024 Alto = 600 @@ -85,6 +86,8 @@ class Juego(): self.eventos() self.naves.update() + self.balas.update() + self.explosiones.update() pygame.event.clear() self.naves.draw(self.ventana) @@ -102,6 +105,25 @@ class Juego(): pygame.quit() sys.exit(0) - + if tecla[pygame.K_UP]: + if self.protagonista.nave.rect.y - 5 > 0: + self.protagonista.nave.rect.y -= 5 + + if tecla[pygame.K_DOWN]: + if self.protagonista.nave.rect.y + self.protagonista.nave.rect.h + 5 < self.protagonista.nave.h: + self.protagonista.nave.rect.y += 5 + + if tecla[pygame.K_RIGHT]: + if self.protagonista.nave.rect.x + self.protagonista.nave.rect.w + 5 < self.protagonista.nave.w: + self.protagonista.nave.rect.x += 5 + + if tecla[pygame.K_LEFT]: + if self.protagonista.nave.rect.x - 5 > 0: + self.protagonista.nave.rect.x -= 5 + + if tecla[pygame.K_SPACE]: + bala = Bala(self.protagonista) + self.balas.add(bala) + if __name__ == "__main__": Juego() |