-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalien.py
More file actions
25 lines (20 loc) · 817 Bytes
/
alien.py
File metadata and controls
25 lines (20 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pygame
from pygame.sprite import Sprite
class Alien(Sprite):
"""Uma classe que representa um único alienígena da frota."""
def __init__(self, ai_settings, screen):
"""Inicializa o alienígena e define sua posição inicial"""
super(Alien, self).__init__()
self.screen = screen
self.ai_settings = ai_settings
# Carrega a imagem do alienígena e define seu atributo rect
self.image = pygame.image.load('images/alien.bmp')
self.rect = self.image.get_rect()
# Inicia cada novo alienígena próximo à parte superior esquerdo da tela
self.rect.x = self.rect.width
self.rect.y = self.rect.height
# Armazena a posição exata do alienígena
self.x = float(self.rect.x)
def blitme(self):
"""Desenha o alienígena em sua posição atual."""
self.screen.blit(self.image, self.rect)