46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
#!/usr/bin/python3
|
|
|
|
import pygame
|
|
from wobbl_tools import pg
|
|
from sprite_stacking_engine.engine import Engine
|
|
|
|
|
|
class Moss:
|
|
def __init__(self):
|
|
self.screen = pygame.display.set_mode((1400, 800)) # screen and clock (pygame)
|
|
self.clock = pygame.time.Clock()
|
|
|
|
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)
|
|
|
|
self.running = True
|
|
|
|
def update(self):
|
|
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
|
|
self.engine.update()
|
|
|
|
def draw(self):
|
|
self.engine.draw() # draw the stacked sprite objects
|
|
|
|
self.screen.blit(self.engine.surface, (0, 0)) # draw it onto the real window now
|
|
|
|
pygame.display.flip() # update the window
|
|
|
|
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()
|