from github
This commit is contained in:
@@ -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))
|
||||
Reference in New Issue
Block a user