This commit is contained in:
Kacper 2022-06-09 21:55:35 +02:00
parent 3182e09e9d
commit 9075e96d83
5 changed files with 24 additions and 1 deletions

16
game_objects/hud.py Normal file
View File

@ -0,0 +1,16 @@
import pygame
import settings as s
class HUD(pygame.sprite.Sprite):
def __init__(self):
super(HUD, self).__init__()
self.image = pygame.image.load('./resources/textures/misc/hud.png').convert_alpha()
self.rect = self.image.get_rect()
self.rect.y = s.HEIGHT - self.rect.height
# self.rect.x = s.WIDTH - self.rect.height
self.vel_x = 0
self.vel_y = 0
def update(self):
self.rect.x += self.vel_x
self.rect.y += self.vel_y

View File

@ -2,6 +2,7 @@ from path_search_algorthms import a_star_utils
import pygame as pg
from settings import *
from game_objects import utils
from game_objects.hud import HUD
vec = pg.math.Vector2
@ -21,6 +22,10 @@ class Player(pg.sprite.Sprite):
self.__rotation = a_star_utils.Rotation.RIGHT
self.mass = 0
self.hud = HUD()
self.hud_group = pg.sprite.Group()
self.hud_group.add(self.hud)
def rotation(self) -> a_star_utils.Rotation:
return self.__rotation
@ -66,6 +71,7 @@ class Player(pg.sprite.Sprite):
utils.collide_with_walls(self, self.game.wallTiles, 'y')
self.rect.center = self.hit_rect.center
self.hud_group.update()
def get_actual_coords(self):
# return (self.rect.x / 64, self.rect.y / 64)

View File

@ -204,6 +204,7 @@ class Game():
if self.debug_mode:
pg.draw.rect(self.screen, CYAN, self.camera.apply_rect(sprite.hit_rect), 1)
self.player.hud_group.draw(self.screen)
# finally update screen
pg.display.flip()

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -7,7 +7,7 @@ RED = (255, 0, 0)
#game settings
WIDTH = 1024
WIDTH = 1024+200
HEIGHT = 768
FPS = 60