-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·110 lines (94 loc) · 3.35 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
import sys
import pygame
sys.path.append('./InputEngine')
sys.path.append("./GraphicsEngine")
sys.path.append('./Objects')
sys.path.append("./PhysicsEngine")
sys.path.append("./PlayerEngine")
sys.path.append("./LevelEditor")
sys.path.append("./SpriteEngine")
sys.path.append("./CollisionEngine")
sys.path.append("./AnimationEngine")
sys.path.append("./ScrollEngine")
sys.path.append("./AudioEngine")
sys.path.append("./EnemyEngine")
sys.path.append("./EnvironmentEngine")
sys.path.append("./ItemEngine")
import input_engine
import graphics_engine
import physics_engine
import player_engine
import level_editor
import sprite_engine
import collision_engine
import animation_engine
import scroll_engine
import audio_engine
import enemy_engine
import environment_engine
import item_engine
'''Hungarian Notation
e = engine
l = list
o = object
'''
e_inputs = input_engine.InputsEngine()
e_graphics = graphics_engine.GraphicsEngine()
e_physics = physics_engine.PhysicsEngine()
e_player = player_engine.PlayerEngine()
e_level_editor = level_editor.LevelEditor()
e_sprite = sprite_engine.SpriteEngine()
e_collision = collision_engine.CollisionEngine()
e_animation = animation_engine.AnimationEngine()
e_scroll = scroll_engine.ScrollEngine()
e_audio = audio_engine.AudioEngine()
e_enemy = enemy_engine.EnemyEngine()
e_environment = environment_engine.EnvironmentEngine()
e_item = item_engine.ItemEngine()
l_game_objects = list()
# Start clock
clock = pygame.time.Clock()
# simulation runtime variables
pygame_events = None
delta_t = 0
FPS = 120
events = {'TextInput': None,
'KeyDown': None,
'MouseWheel': None}
# main game loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.TEXTINPUT:
e_level_editor.text_box_ui.event = event
events['TextInput'] = event
if event.type == pygame.KEYDOWN:
e_level_editor.text_box_ui.event = event
events['KeyDown'] = event
if event.type == pygame.MOUSEWHEEL:
e_level_editor.c_scene.event = event
e_level_editor.attribute_ui.event = event
events['MouseWheel'] = event
input_dict = e_inputs.update()
e_graphics.update(GameObjectsList=l_game_objects, LevelEditor=e_level_editor, Events=events)
if not e_level_editor.edit:
for objects in e_graphics.render_buffer:
e_collision.update(GraphicsEngine=e_graphics, CurrentObject=objects)
e_physics.update(GameObject=objects, DeltaT=delta_t)
e_sprite.update(GameObject=objects, DeltaT=delta_t)
e_player.update(InputDict=input_dict, PlayerObject=objects, DeltaT=delta_t)
e_enemy.update(GameObject=objects, ScrollEngine=e_scroll)
e_animation.update(GameObject=objects)
e_environment.update(GameObject=objects)
e_item.update(GameObject=objects)
e_audio.update(GameObject=objects)
e_scroll.update(GameObject=objects)
e_scroll.scroll_objects(GameObjects=l_game_objects, LevelEditor=e_level_editor, InputDict=input_dict)
e_level_editor.update(InputDict=input_dict, GameObjects=l_game_objects, GraphicsEngine=e_graphics)
events = {'TextInput': None,
'KeyDown': None,
'MouseWheel': None}
delta_t = clock.tick(FPS) / 1000
pygame.quit()