def update(self, deltatime): self.position[1] += ENEMY_SPEED * deltatime time_elapsed = time.time() - self.spawntime scale = self.scale * self.GROWTH_RATE**time_elapsed self.image = pygame.transform.scale(self.original_image, intlist(scale*screen_rect)) self.rect = self.image.get_rect() self.rect.center = intlist(self.position * screen_rect) self.rect.bottom = intlist(self.position * screen_rect)[1]
def update(self, deltatime, keys): if keys[K_RIGHT]: self.position[0] += PLAYER_SPEED * deltatime if keys[K_LEFT]: self.position[0] -= PLAYER_SPEED * deltatime self.rect = self.image.get_rect() self.rect.center = intlist(self.position * screen_rect)
def __init__(self, left=True): super().__init__() self.image = pygame.image.load('ship.png') self.left = left self.scale = np.array([ENEMY_MIN_SIZE, ENEMY_MIN_SIZE]) self.image = pygame.transform.scale(self.image, intlist(self.scale*screen_rect)) self.image = pygame.transform.rotate(self.image, 180) self.original_image = self.image r = np.random.uniform(0.8, 0.93) xpos = 1 - r if left else r self.position = np.array([xpos, 0.0]) self.spawntime = time.time()
def __init__(self): super().__init__() self.image = pygame.image.load('ship.png') self.scale = np.array([0.1, 0.1]) self.image = pygame.transform.scale(self.image, intlist(self.scale*screen_rect[0])) self.position = np.array([0.5, 0.94])
def update(self, deltatime): self.position[1] -= deltatime * BULLET_SPEED self.rect.center = intlist(self.position * screen_rect)
def __init__(self, x): super().__init__() self.image = pygame.Surface(intlist(screen_rect[1] * np.array([0.03, 0.03]))) self.image.fill([0, 255, 0]) self.rect = self.image.get_rect() self.position = np.array([x, 0.95])