33 lines
936 B
Python
33 lines
936 B
Python
|
|
import pygame
|
||
|
|
|
||
|
|
|
||
|
|
class Player:
|
||
|
|
def __init__(self, color, image: pygame.Surface, pos: pygame.Vector2):
|
||
|
|
self.pos = pos
|
||
|
|
self.image = image
|
||
|
|
self.rect = image.get_frect(center=pos)
|
||
|
|
self.mask = pygame.mask.from_surface(self.image)
|
||
|
|
self.color = color
|
||
|
|
|
||
|
|
def overlaps_rect(self, rect):
|
||
|
|
pass
|
||
|
|
|
||
|
|
def update(self, obstacle: pygame.Rect):
|
||
|
|
self.rect.x = self.pos.x
|
||
|
|
self.rect.y = self.pos.y
|
||
|
|
|
||
|
|
# offset = (int(self.rect.x) - int(obstacle.x), int(self.rect.y) - int(obstacle.y))
|
||
|
|
# obstacle_mask = pygame.Mask((obstacle.width, obstacle.height))
|
||
|
|
|
||
|
|
# if self.mask.overlap(obstacle_mask, offset=offset):
|
||
|
|
# print("OVERLAP")
|
||
|
|
|
||
|
|
# if self.rect.colliderect(obstacle):
|
||
|
|
# self.color = "red"
|
||
|
|
|
||
|
|
# else:
|
||
|
|
# self.color = "white"
|
||
|
|
|
||
|
|
def render(self, surface: pygame.Surface):
|
||
|
|
surface.blit(self.image, self.rect)
|
||
|
|
|