This commit is contained in:
Waylon Walker 2023-03-19 12:27:00 -05:00
parent 44ecb00701
commit 80d7ebf7eb
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
7 changed files with 189 additions and 294 deletions

28
cave_survival/player.py Normal file
View file

@ -0,0 +1,28 @@
import pygame
from cave_survival.config import config
from cave_survival.console import console
class Player:
def __init__(self):
self.width = 16
self.height = 16
self.x = config.screen_width / 2
self.y = config.screen_height / 2
self.speed = 5
self.image = pygame.image.load("player.png").convert_alpha()
self.x_last = self.x
self.y_last = self.y
self.hitbox_surface = pygame.Surface((self.width, self.height))
self.hitbox_surface.fill(config.WHITE)
pygame.draw.rect(
self.hitbox_surface, (255, 0, 0), (0, 0, self.width, self.height), 1
)
self.hitbox_surface.set_alpha(0)
def draw(self, surface, offset):
surface.blit(
pygame.transform.scale(self.image, (16, 16)),
(self.x - 8 - offset.x, self.y - 8 - offset.y),
)