This repository has been archived by the owner on Jan 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
82 lines (67 loc) · 2.27 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'''
Author: Kyle Charters
The Raycaster program
Level Features:
- Name
- Ceiling Color
- Floor Color
- Outer Wall Type
- Texture Packs
- Sprites
- Walls
Game Features:
- Level Selector
- Level Player
- Level Editor
- Settings
'''
def start():
#Initialize pygame before everything else because of dependencies
import pygame
pygame.display.init()
pygame.font.init()
import setting
import state
import file
import utility
#Loads settings into memory
setting.loadSettings()
#Sets the pygame window title to "Raycaster"
pygame.display.set_caption("Raycaster")
#Sets the window icon to the image at "ui/icon.png"
pygame.display.set_icon(file.loadImage("core/ui/icon.png"))
#Create display and save the display surface
window = pygame.display.set_mode(setting.resolution())
#Create a pygame clock for time management
fpsclock = pygame.time.Clock()
#Create a statemanager and load all of the states
statemanager = state.StateManager(0, (state.Main(),
state.Selector(),
state.Play(),
state.Pause(),
state.Settings(),
state.Editor()))
#Create the debugger class
debugger = utility.Debugger()
running = True
while running:
#Find current update data
events = pygame.event.get()
keys = pygame.key.get_pressed()
delta = min(fpsclock.get_time() / 1000, 0.5)
#Update the current state as well as the debugger
statemanager.update(window, delta, events, keys)
debugger.update(window, delta, events, keys, fpsclock)
#Quit game if pygame called a quit event
for event in events:
if event.type == pygame.QUIT:
running = False
#Swaps the screen buffer (Same as .update() except it updates entire surface)
pygame.display.flip()
fpsclock.tick(60)
#Saves the settings to settings.json
setting.saveSettings()
#Exits pygame and the console
pygame.quit()
if __name__ == "__main__":
start()