-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoadrunner.py
More file actions
38 lines (28 loc) · 1.01 KB
/
Roadrunner.py
File metadata and controls
38 lines (28 loc) · 1.01 KB
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
import pygame
# initialize pygame
pygame.init()
# create game display
game_display = pygame.display.set_mode( (640,640) )
print( pygame.display.Info() )
game_clock = pygame.time.Clock()
# Eigene Module:
import scenes
###################### Main Loop ##############################
# Festlegen mit welcher Szene gestartet werden soll:
running_scene = scenes.Level1()
last_ticks = pygame.time.get_ticks()
# Ausführen und auf Szenenwechsel bzw. Ende warten:
while(running_scene):
running_scene = running_scene.schedule()
game_clock.tick(60)
pygame.display.update()
# Framerate ausgeben:
now_ticks = pygame.time.get_ticks()
if now_ticks-last_ticks > 2000:
print( "FPS: {0:.2f}".format(game_clock.get_fps()) )
last_ticks = now_ticks
# Mit Spacetaste anhalten:
while pygame.key.get_pressed()[ pygame.K_SPACE ]:
pygame.event.get() # anscheinend nötig für get_pressed()
if pygame.key.get_pressed()[ pygame.K_b ]:
pygame.quit()