-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
51 lines (41 loc) · 1.38 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
import os
try:
import pygame
except:
os.system('pip install pygame')
import pygame
import sys, time
import settings
import colors
import handler_frame
class Game:
def __init__(self):
pygame.init()
pygame.display.set_caption('8 Puzzle Report')
self.clock = pygame.time.Clock()
self.display_surface = pygame.display.set_mode((settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT))
self.handlerFrame = handler_frame.HandlerFrame(self.display_surface)
def run(self):
last_time = time.time()
while True:
dt = time.time() - last_time
last_time = time.time()
# Handler Event
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
self.handlerFrame.current_frame.ui_event(event)
# Refresh Display
self.display_surface.fill(colors.WHITE)
# Update Display
self.handlerFrame.current_frame.update(dt)
# Render Display
self.handlerFrame.current_frame.render(self.display_surface)
pygame.display.update()
self.clock.tick(settings.FRAME_RATE)
if __name__ == '__main__':
game = Game()
game.run()
# Final Build