-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (53 loc) · 2.31 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
# Import the 'pygame' module
import pygame
# Import the 'sys' module
import sys
# Import the 'random' module
import random
# From the classes folder, import the module 'planet'
from classes import planet
# From the scenes folder, import the module 'planetScene'
from scenes import planetScene
# From the methods folder, import the module 'loadingSceneSetup'
from methods import loadingSceneSetup, planetSceneSetup
# Create a new class called 'Application'
class Application:
# The constructor function
def __init__(self, width, height):
# Assign the value 'windowWidth' to the class variable 'width'
self.windowWidth = width
# Assign the value 'windowHeight' to the class variable 'height'
self.windowHeight = height
# Assign the value 'True' to the class variable 'running'
self.running = True
# Assign an empty dictionary to the class variable 'planetDict'
self.planetDict = {}
# Initialise pygame
pygame.init()
# Create a pygame window with the dimensions 'self.windowWidth' and 'self.windowHeight' and make the window hardware accelerated and double buffed
self.display = pygame.display.set_mode(
(self.windowWidth, self.windowHeight), pygame.HWSURFACE | pygame.DOUBLEBUF)
# Set the title of the window to 'Raize'
pygame.display.set_caption("Raize")
self.scene = planetScene
planetSceneSetup.init(self)
# While 'self.running' is True
while self.running:
self.display.blit(self.backgroundImage, (0,0))
# For each event in the list 'pygame.event.get()'
for event in pygame.event.get():
# If the close button is pressed in the window
if event.type == pygame.QUIT:
# Set 'self.running' to False
self.running = False
# Quit the pygame window
pygame.quit()
# Exit the python script
sys.exit()
self.scene.play(self)
# Update the pygame window
pygame.display.update()
# If this Python file is run directly
if __name__ == "__main__":
# Instanciate a new Application class with the parameters '800' and '650'
game = Application(1080, 960)