diff options
Diffstat (limited to 'Nave.py')
-rwxr-xr-x | Nave.py | 42 |
1 files changed, 9 insertions, 33 deletions
@@ -7,17 +7,17 @@ import random import pygame from pygame.locals import * -''' -DIRECTORIOBASE = os.path.dirname(__file__) +DIRECTORIOBASE = os.path.dirname(__file__) +''' IMAGEN_NAVE = os.path.join(DIRECTORIOBASE, 'Imagenes', 'Naves', 'Nave.png') IMAGEN_NAVE_ENEMIGA = os.path.join(DIRECTORIOBASE, - 'Imagenes', 'Naves', 'enemy02.png') + 'Imagenes', 'Naves', 'enemy02.png')''' IMAGEN_BALA = os.path.join(DIRECTORIOBASE, - 'Imagenes', 'Bala.png')''' + 'Imagenes', 'Bala.png') class Nave(pygame.sprite.Sprite): """Nave.""" @@ -34,31 +34,7 @@ class Nave(pygame.sprite.Sprite): self.h = pygame.display.Info().current_h self.rect.center = (self.w/2, self.h/2) - - def update(self): - """Actualiza la nave, segĂșn eventos del teclado.""" - - tecla = pygame.key.get_pressed() - - if tecla[pygame.K_UP]: - if self.rect.y - 5 > 0: - self.rect.y -= 5 - - if tecla[pygame.K_DOWN]: - if self.rect.y + self.rect.h + 5 < self.h: - self.rect.y += 5 - - if tecla[pygame.K_RIGHT]: - if self.rect.x + self.rect.w + 5 < self.w: - self.rect.x += 5 - - if tecla[pygame.K_LEFT]: - if self.rect.x - 5 > 0: - self.rect.x -= 5 - - if tecla[pygame.K_SPACE]: - print "Disparar" - + class Enemigo(Nave): """Nave.""" @@ -95,10 +71,10 @@ class Bala(pygame.sprite.Sprite): self.image = pygame.image.load(IMAGEN_BALA) self.rect = self.image.get_rect() - xnave = self.propietario.rect.x - ynave = self.propietario.rect.y - wnave = self.propietario.rect.w - hnave = self.propietario.rect.h + xnave = self.propietario.nave.rect.x + ynave = self.propietario.nave.rect.y + wnave = self.propietario.nave.rect.w + hnave = self.propietario.nave.rect.h self.rect.x = xnave + wnave / 2 - self.rect.w / 2 self.rect.y = ynave - self.rect.h/2 |