from github

This commit is contained in:
jonas
2024-10-29 17:18:30 +01:00
commit b0f85b5c87
63 changed files with 1781 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
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))