sep-pm-platformer/project/ui_elements/Background.py

32 lines
938 B
Python
Raw Normal View History

2023-03-28 16:59:29 +02:00
from typing import Optional
import pygame
from pygame import Surface
from physics.TickData import TickData
from sprite.BoundingBox import BoundingBox
from ui_elements.UiElement import UiElement
class Background(UiElement):
def __init__(self, x_pos: float, y_pos: float, width: float, height: float, color: tuple):
super().__init__()
self.x_pos = x_pos
self.y_pos = y_pos
self.width = width
self.height = height
self.color = color
def tick(self, tick_data: TickData):
pass
def render_sprite_image(self) -> Optional[Surface]:
surface = pygame.Surface((self.width, self.height), pygame.SRCALPHA)
background_rect = pygame.Rect(self.x_pos, self.y_pos, self.width, self.height)
pygame.draw.rect(surface, self.color, background_rect)
return surface
def get_bounding_box(self) -> BoundingBox:
return BoundingBox(-1, -1, 0, 0)