/
__init__.py
53 lines (40 loc) · 1.49 KB
/
__init__.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
52
53
import pygame
import sys
import cProfile
pygame.init()
import game
from base.init import *
from base.frame import *
from base.drawing import *
initAssets()
accumelator = 0
lastTime = pygame.time.get_ticks() - 1
from mainmenu import *
game.scene = MainMenu()
game.fonts['menu'] = pygame.font.Font( 'fonts/kenvector_future_thin.ttf', 48 )
game.fonts['resources'] = pygame.font.Font( 'fonts/kenvector_future_thin.ttf', 16 )
game.fonts['description'] = pygame.font.Font( 'fonts/kenvector_future_thin.ttf', 8 )
game.fonts['gameover1'] = pygame.font.Font( 'fonts/kenvector_future_thin.ttf', 32 )
game.fonts['gameover2'] = pygame.font.Font( 'fonts/kenvector_future_thin.ttf', 12 )
game.fonts['gameover3'] = pygame.font.Font( 'fonts/kenvector_future_thin.ttf', 8 )
while game.gameIsRunning:
curTime = pygame.time.get_ticks()
lastFrameTime = curTime - lastTime
lastTime = curTime
if not game.isPaused:
accumelator += lastFrameTime
game.accumelator = accumelator / 200
frameTime = lastFrameTime / 1000 #Given in miliseconds, converting it to a float of unit seconds
game.scene.doFrame( frameTime )
pygame.display.set_caption( 'Self Defense.' )
if accumelator > 200:
#cProfile.run( 'game.scene.doTick()' )
game.scene.doTick()
skipped = -1
while accumelator > 200:
accumelator -= 200
skipped += 1
if skipped > 0:
print( 'Skipping %d ticks.' % skipped )
sys.stdout.flush()
pygame.display.flip()