This commit is contained in:
2021-09-01 11:26:29 +02:00
parent 47d06204ea
commit 57863eb08a
11 changed files with 88 additions and 193 deletions

25
UI/Objects/Scene.py Normal file
View File

@@ -0,0 +1,25 @@
import pygame.transform
from Objects.Screen import Screen
from numpy import array as a
import numpy as np
class Scene(Screen):
def __init__(self, width: float, height: float, font_size: int, screen_size: a, bg=(60, 60, 60)):
super().__init__(width, height, font_size, screen_size)
self.bg = bg
self.r_objects = [] # resizable Objects
self.nr_objects = [] # non-resizable Objects
def redraw(self):
self.s_.fill(self.bg)
for object_ in self.r_objects:
object_.blit()
rs = pygame.transform.scale(self.s_, self.screen_size)
self.s.blit(rs, [0, 0])
pygame.display.update()

24
UI/Objects/Screen.py Normal file
View File

@@ -0,0 +1,24 @@
from numpy import array as a
import numpy as np
import pygame
class Screen:
def __init__(self, width: float, height: float, font_size: int, screen_size: a):
pygame.init()
self.width = width
self.height = height
self.size = a([float(width), float(height)])
self.screen_size = a(screen_size)
self.matrix = a([
[screen_size[0] / width, 0],
[0, screen_size[1] / height]
])
self.s_ = pygame.Surface([width, height])
self.s = pygame.display.set_mode(screen_size)
self.font_size = font_size
self.center = a([width, height]) / 2

View File

@@ -0,0 +1,15 @@
import pygame.draw
from numpy import array as a
import numpy as np
class Rect:
def __init__(self, pos, size, color, scene):
self.pos = pos
self.size = size
self.color = color
self.rect = pygame.Rect(self.pos, self.size)
self.scene = scene
def blit(self):
pygame.draw.rect(self.scene.s_, self.color, self.rect)