-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
152 lines (112 loc) · 3.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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import sys
import pygame
sys.path.append('./GraphicsEngine')
sys.path.append('./InputsEngine')
sys.path.append('./UIEngine')
sys.path.append('./PhysicsEngine')
sys.path.append('./MechanicsEngine/PlayerEngine')
sys.path.append('./MechanicsEngine/PlatformsEngine')
sys.path.append('./MechanicsEngine/EnemyEngine')
sys.path.append('./GameObjects')
sys.path.append('./CollisionEngine')
sys.path.append('./LevelBuilder')
sys.path.append('./LevelHandler')
sys.path.append('./AnimationSystem')
sys.path.append('./MechanicsEngine/BlockEngine')
sys.path.append('./MechanicsEngine/PowerUpEngine')
#Custom Libraries Kinda
import GraphicsEngine
import InputsEngine
import UIEngine
import PhysicsEngine
import PlayerEngine
import PlatformsEngine
import GameObject
import CollisionEngine
import LevelBuilder
import LevelHandler
import EnemyEngine
import AnimationSystem
import BlockEngine
import PowerUpEngine
# Initialize Inputs engine
IE = InputsEngine._InputsEngine()
# Initialize UI Engine
UIE = UIEngine._UIEngine()
# Initialize Physics Engine
PE = PhysicsEngine._PhysicsEngine()
# Initialize Player Engine
PlE = PlayerEngine._PlayerEngine()
# Initialize Enemy Engine
EE = EnemyEngine._EnemyEngine()
# Initialize Platforms Engine
PfE = PlatformsEngine._PlatformsEngine()
# Initialize Graphics Engine
GE = GraphicsEngine._GraphicsEngine()
GE._setScreenSize(1280,720)
# Initialize Collision Engine
CE = CollisionEngine._CollisionEngine()
# Initialize Level Builder
LB = LevelBuilder._LevelBuilder()
# Initialize Level Handler
LH = LevelHandler._LevelHandler()
# Initialize Animation System
AS = AnimationSystem._AnimationSystem()
#Initialize Block Engine
BE = BlockEngine._BlockEngine()
#Initialize PowerUpEngine
PUP = PowerUpEngine._PowerUpEngine()
# This will have to change
# Initialize GameObjects
GameObjects = list()
PlayerObject = GameObject._GameObject()
PlayerObject._set_sub_class('player')
PlayerObject._set_image_path('./Assets/PlayerSprites/mario_32x32_idle_right.png')
PlayerObject._set_image()
PlayerObject._set_sprite_size(PlayerObject.image)
PlayerObject._set_rect(PlayerObject.sprite_size)
PlayerObject._set_mask()
GameObjects.append(PlayerObject)
levelObjects = list()
clock = pygame.time.Clock()
collisionList = list()
collisionList.extend(GameObjects)
collisionList.extend(levelObjects)
pygame_events = None
# simulation runtime variables
delta_t = 0
FPS = 120
# main loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame_events = pygame.event.get()
# Inputs Engine
input_dict = IE.main_loop(GameObjects,delta_t,pygame_events)
if not LB.edit:
# UI Engine
# UIE.main_loop()
# PlayerMechanics Engine
PlE.main_loop(GameObjects, delta_t, input_dict, CE, LH)
# Enemy Engine
EE.main_loop(GameObjects, PlE, GE)
# Animation System
AS.main_loop(GameObjects, input_dict, LH)
# Block Engine
BE.main_loop(GameObjects, levelObjects, PlE, delta_t)
# PowerUp Engine
PUP.main_loop(GameObjects, LH, PlE,GE)
# Physics Engine
PE.main_loop(GameObjects, delta_t, LH)
# Collision Engine
CE.main_loop(collisionList, GE, input_dict, GE.screen)
# Level Handler
LH.main_loop(LH, GameObjects, levelObjects, collisionList, GE.screen, PlE, LB)
# Graphics Engine
GE.main_loop(GameObjects, levelObjects, LH,LB)
# Level Builder
LB.main_loop(input_dict, GE.screen, levelObjects, collisionList, LH, PlE, GameObjects,GE)
delta_t = clock.tick(FPS)/1000
pygame.quit()