Added some Comments.
This commit is contained in:
parent
85a9518faf
commit
230f64f0b9
1 changed files with 11 additions and 9 deletions
20
moss.py
20
moss.py
|
@ -7,25 +7,27 @@ from sprite_stacking_engine.engine import Engine
|
|||
|
||||
class Moss:
|
||||
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.engine = Engine(self)
|
||||
self.time = 0
|
||||
self.delta_time = 0.01
|
||||
|
||||
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}")
|
||||
self.delta_time = self.clock.tick(60)
|
||||
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()
|
||||
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):
|
||||
self.time = pygame.time.get_ticks() * 0.001
|
||||
|
|
Loading…
Reference in a new issue