Files
pacmanpythondhbw/Game_Package/Entity.py
T
2024-10-29 17:18:30 +01:00

29 lines
939 B
Python

import pygame as pg
from DrawType import DrawType
from Vec import Vec
class Entity:
def __init__(self, start_position: Vec, start_size: Vec):
self.position = Vec(start_position.x, start_position.y)
self.size = start_size
def draw(self, screen, color, draw_type: DrawType = DrawType.rect, grid_cell_size=0, image=None):
# Either draw a...
match draw_type:
# ...Rect...
case DrawType.rect:
pg.draw.rect(screen, color, (self.position.x, self.position.y, self.size.x, self.size.y))
# ... or a circle
case DrawType.circle:
pg.draw.circle(screen, color, (self.position.x + grid_cell_size / 2,
self.position.y + grid_cell_size / 2), (self.size.x + self.size.y) / 2)
case DrawType.image:
screen.blit(image, (self.position.x, self.position.y))