Skip to content

Commit

Permalink
Modified the algorithm used for FPS implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
1024Adam committed Oct 3, 2017
1 parent a59d2ee commit 57754b0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions infinite_maze/infinite_maze.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pygame
from pygame.locals import *
from pygame.time import *
from pygame import time
from Player import Player
from Game import Game
from Line import Line
Expand All @@ -17,10 +17,9 @@ def maze():

game.getClock().reset()
keys = pygame.key.get_pressed()

mills = 0
while (game.isPlaying()):
while (game.isActive()):
mills = game.getClock().getFullTime()
game.updateScreen(player, lines)

prevKeys = keys
Expand Down Expand Up @@ -117,9 +116,9 @@ def maze():

# Process FPS
processTime = game.getClock().getFullTime() - mills
if (processTime < 16):
delay(16 - processTime)

if (processTime <= 16):
time.delay(16 - processTime)
mills = game.getClock().getFullTime()

# Game has ended
game.printEndDisplay()
Expand Down Expand Up @@ -147,6 +146,6 @@ def maze():
for event in pygame.event.get():
if (event.type == pygame.QUIT):
game.quit()

game.cleanup()
exit(0)

0 comments on commit 57754b0

Please sign in to comment.