diff --git a/data/textures/entity/player/player.png b/data/textures/entity/player/player.png index 44f7420..b38e2ae 100644 Binary files a/data/textures/entity/player/player.png and b/data/textures/entity/player/player.png differ diff --git a/game.py b/game.py index 293195d..af2a5cc 100644 --- a/game.py +++ b/game.py @@ -25,17 +25,18 @@ class Game: self.player_pos = pygame.Vector2( self.screen.get_width() / 2, self.screen.get_height() / 2 ) - self.player = Player(self.player_pos, width=PLAYER_SIZE, height=PLAYER_SIZE) - # Flashlight - self.flashlight_player = Flashlight(self, self.player) # Assets self.assets = { "floor_01": load_image("level/ground/floor_1.png"), "plant_01": load_image("items/furniture/plants/plant.png"), "wall": load_image("level/walls/wall_0.png"), + + "player": load_image("entity/player/player.png"), } + self.player = Player(self.player_pos, width=PLAYER_SIZE, height=PLAYER_SIZE, image=self.assets["player"]) + self.flashlight_player = Flashlight(self, self.player) self.level = Level( game=self, diff --git a/scripts/player.py b/scripts/player.py index 1e9d1a0..82b19f4 100644 --- a/scripts/player.py +++ b/scripts/player.py @@ -5,15 +5,17 @@ from scripts.constants import * class Player: - def __init__(self, pos: pygame.Vector2, width, height): + def __init__(self, pos: pygame.Vector2, width, height, image=None): self.pos: Vector2 = pos self.width: float = width self.height: float = height self.speed = 150 + self.image = image self.rect = pygame.Rect( self.pos[0] - self.width / 2, self.pos[1] - self.height / 2, width, height ) + def update(self, walls, dt): keys = pygame.key.get_pressed() direction = pygame.Vector2( @@ -59,5 +61,12 @@ class Player: self.rect.top = wall.bottom self.pos.y = self.rect.centery - def render(self, surface): - pygame.draw.rect(surface, (255, 0, 0), self.rect) + + def render(self, surface: pygame.Surface): + if not self.image: + pygame.draw.rect(surface, self.color, self.rect) + else: + surface.blit( + self.image, + (self.pos[0]-TILE_SIZE/2, self.pos[1]-TILE_SIZE/2-10, self.image.get_width(), self.image.get_height()), + )