Added some Comments.

This commit is contained in:
The Wobbler 2024-09-26 17:15:15 +02:00
parent 85a9518faf
commit 230f64f0b9

20
moss.py
View file

@ -7,25 +7,27 @@ from sprite_stacking_engine.engine import Engine
class Moss: class Moss:
def __init__(self): def __init__(self):
self.screen = pygame.display.set_mode((1400, 800)) self.screen = pygame.display.set_mode((1400, 800)) # screen and clock (pygame)
self.clock = pygame.time.Clock() self.clock = pygame.time.Clock()
self.engine = Engine(self)
self.time = 0 self.engine = Engine(self) # initialize the sprite stacking engine
self.delta_time = 0.01
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 self.running = True
def update(self): def update(self):
pygame.display.set_caption(f"{self.clock.get_fps(): .1f}") pygame.display.set_caption(f"{self.clock.get_fps(): .1f}") # set title to fps
self.delta_time = self.clock.tick(60) self.delta_time = self.clock.tick(60) # get the delta time using pygames's clock module
self.engine.update() self.engine.update()
def draw(self): def draw(self):
self.engine.draw() self.engine.draw() # draw the stacked sprite objects
self.screen.blit(self.engine.surface, (0, 0)) self.screen.blit(self.engine.surface, (0, 0)) # draw it onto the real window now
pygame.display.flip() pygame.display.flip() # update the window
def get_time(self): def get_time(self):
self.time = pygame.time.get_ticks() * 0.001 self.time = pygame.time.get_ticks() * 0.001