cdec/tapwater.py
2025-10-12 08:54:30 +02:00

23 lines
835 B
Python

import pygame
from settings import PLAYER_SIZE, WATER_SIZE, WATER_SPEED
class TapWater:
def __init__(self, x, y, direction):
self.x = x + PLAYER_SIZE // 2 - WATER_SIZE // 2
self.y = y + PLAYER_SIZE // 2 - WATER_SIZE // 2
self.direction = direction
self.rect = pygame.Rect(self.x, self.y, WATER_SIZE, WATER_SIZE)
def move(self):
if self.direction == "up":
self.y -= WATER_SPEED
elif self.direction == "down":
self.y += WATER_SPEED
elif self.direction == "left":
self.x -= WATER_SPEED
elif self.direction == "right":
self.x += WATER_SPEED
self.rect.topleft = (self.x, self.y)
def draw(self, win, ox, oy):
pygame.draw.rect(win, (0, 180, 255), (self.x - ox, self.y - oy, WATER_SIZE, WATER_SIZE))