-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (43 loc) · 1.42 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
52
# Example file showing a circle moving on screen
import pygame
import pygame.freetype # Import the freetype module.
from src.levelTools import LevelController
from src.globals import GameVariables
# pygame setup
pygame.init()
# set caption
pygame.display.set_caption("Da2 Space invaders")
# load the image
gameIcon = pygame.image.load("src/assets/base.png")
# set icon
pygame.display.set_icon(gameIcon)
GLOBALS = GameVariables()
GLOBALS.screen = pygame.display.set_mode((600, 600))
# define fonts
font_dir = "src/assets/font.ttf"
GLOBALS.game_fonts.base = pygame.freetype.Font(font_dir, 16)
GLOBALS.game_fonts.title = pygame.freetype.Font(font_dir, 24)
# set clock
clock = pygame.time.Clock()
running = True
# start level controller
level = LevelController()
while running:
# poll for events
# pygame.QUIT event means the user clicked X to close your window
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# fill the screen with a color to wipe away anything from last frame
GLOBALS.screen.fill("black")
# render level
level.execute()
# flip() the display to put your work on screen
pygame.display.flip()
# limits FPS to 60
# dt is delta time in seconds since last frame, used for frame rate
# independent physics.
dt = clock.tick(60) / 1000
# set delta time that player use to move itself
GLOBALS.delta_time = dt
pygame.quit()