2024-07-19 18:24:45 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import pygame
|
|
|
|
from wobbl_tools import pg
|
|
|
|
from sprite_stacking_engine.engine import Engine
|
|
|
|
|
|
|
|
|
|
|
|
class Moss:
|
|
|
|
def __init__(self):
|
2024-09-26 17:15:15 +02:00
|
|
|
self.screen = pygame.display.set_mode((1400, 800)) # screen and clock (pygame)
|
2024-07-19 18:24:45 +02:00
|
|
|
self.clock = pygame.time.Clock()
|
2024-09-26 17:15:15 +02:00
|
|
|
|
|
|
|
self.engine = Engine(self) # initialize the sprite stacking engine
|
|
|
|
|
|
|
|
self.time = 0 # initialize the time (milliseconds since start)
|
|
|
|
self.delta_time = 0.01 # initialize delta time (time it takes to draw a frame)
|
2024-07-19 18:24:45 +02:00
|
|
|
|
|
|
|
self.running = True
|
|
|
|
|
|
|
|
def update(self):
|
2024-09-26 17:15:15 +02:00
|
|
|
pygame.display.set_caption(f"{self.clock.get_fps(): .1f}") # set title to fps
|
|
|
|
self.delta_time = self.clock.tick(60) # get the delta time using pygames's clock module
|
2024-07-19 18:24:45 +02:00
|
|
|
self.engine.update()
|
|
|
|
|
|
|
|
def draw(self):
|
2024-09-26 17:15:15 +02:00
|
|
|
self.engine.draw() # draw the stacked sprite objects
|
2024-07-19 18:24:45 +02:00
|
|
|
|
2024-09-26 17:15:15 +02:00
|
|
|
self.screen.blit(self.engine.surface, (0, 0)) # draw it onto the real window now
|
2024-07-19 18:24:45 +02:00
|
|
|
|
2024-09-26 17:15:15 +02:00
|
|
|
pygame.display.flip() # update the window
|
2024-07-19 18:24:45 +02:00
|
|
|
|
|
|
|
def get_time(self):
|
|
|
|
self.time = pygame.time.get_ticks() * 0.001
|
|
|
|
|
|
|
|
def tick(self):
|
|
|
|
self.engine.check_events()
|
|
|
|
self.get_time()
|
|
|
|
self.update()
|
|
|
|
self.draw()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
game = Moss()
|
|
|
|
|
|
|
|
while game.running:
|
|
|
|
game.tick()
|