This repository has been archived by the owner on Aug 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSFGE.py
355 lines (257 loc) · 6.5 KB
/
SFGE.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
class Color:
Red = 0
Green = 0
Blue = 0
Yellow = 0
Black = 0
White = 0
Magenta = 0
Cyan = 0
Transparent = 0
class Vector2f:
"""SFML and default SFGE Vector type when not working on the physic"""
def __init__(self):
self.x = 0.0
self.y = 0.0
self.magnitude = 0.0
class Vec2f:
def __init__(self):
self.x = 0.0
self.y = 0.0
self.magnitude = 0.0
@staticmethod
def dot(v1, v2):
pass
@staticmethod
def angle_between(v1, v2):
pass
@staticmethod
def lerp(v1, v2, t):
pass
class Vector2i:
"""SFML and default SFGE Vector type when not working on the physic"""
def __init__(self):
self.x = 0
self.y = 0
self.magnitude = 0.0
class p2Vec2:
"""Box2d Vector type used for physics related"""
def __init__(self):
self.x = 0.0
self.y = 0.0
self.magnitude = 0.0
@staticmethod
def dot(v1, v2):
pass
@staticmethod
def cross(v1, v2):
pass
@staticmethod
def lerp(v1, v2, f):
pass
@staticmethod
def angle_between(v1, v2):
pass
def rotate(self, angle):
pass
def normalized(self):
pass
def normalized_self(self):
pass
def to_string(self):
pass
class p2Vec3:
"""Box2d Vector type used for physics related"""
def __init__(self):
self.x = 0.0
self.y = 0.0
self.z = 0.0
self.magnitude = 0.0
@staticmethod
def dot(v1, v2):
pass
@staticmethod
def cross(v1, v2):
pass
@staticmethod
def lerp(v1, v2, f):
pass
@staticmethod
def angle_between(v1, v2):
pass
def rotate(self, angle):
pass
def normalized(self):
pass
def normalized_self(self):
pass
class Sprite:
def set_texture(self, texture):
pass
def load_texture(self, texture_name: str):
pass
class Shape:
def set_fill_color(self, color: Color):
pass
class Timer:
"""Timer used for update loop and """
def __init__(self, time, period):
self.time = 0
self.period = 0
def reset(self):
"""Set the value of time to period"""
pass
def update(self, dt):
"""Update the timer of the dt given as parameter"""
pass
def get_current(self):
"""Get the current ratio of time between 0.0 and 1.0"""
pass
def get_current_time(self):
"""Get the current time from the start """
pass
def is_over(self):
"""Return the status of the termination of the timer"""
pass
class ColliderData:
def __init__(self):
self.body = Body2d()
self.collider = Collider()
self.entity = 0
class System:
def init(self):
pass
def update(self, dt):
pass
def fixed_update(self):
pass
def destroy(self):
pass
def on_contact(self, c1:ColliderData, c2:ColliderData, enter:bool):
pass
def on_draw(self):
pass
class ComponentManager():
def add_component(self, entity):
pass
def destroy_component(self, entity):
pass
def get_component(self, entity):
pass
class SpriteManager(System):
def add_component(self, entity):
return Sprite()
def get_component(self, entity:int):
pass
class ShapeManager(System):
def get_component(self, entity:int):
pass
class TextureManager(System):
pass
class Graphics2dManager(System):
def __init__(self):
self.texture_manager = TextureManager()
self.sprite_manager = SpriteManager()
self.shape_manager = ShapeManager()
def draw_line(self, from_vec:Vec2f, to_vec:Vec2f, color:Color):
pass
def draw_vector(self, v:Vec2f, origin_pos:Vec2f, color:Color):
pass
class SceneManager(System):
def load_scene(self, scene_name):
pass
class Transform2dManager(System, ComponentManager):
pass
class PythonEngine(System):
def load_pycomponent(self, entity, script_path):
pass
class EntityManager(System):
def create_entity(self, wanted_entity):
pass
def destroy_entity(self, entity):
pass
def has_components(self, entity, component):
pass
def get_entities_with_type(self, componentType):
pass
class Body2dManager(System, ComponentManager):
pass
class p2Aabb:
def __init__(self):
self.bottom_left = p2Vec2()
self.top_right = p2Vec2()
class p2World:
def get_quadtree_aabbs(self):
pass
def log_quadtree_bodycount(self):
pass
class Physics2dManager(System):
body2d_manager = None # type: Body2dManager
world = p2World()
def pixel2meter(self, value):
pass
def meter2pixel(self, value: p2Vec2):
pass
class Configuration:
def __init__(self):
self.screen_size = Vec2f()
self.fixed_dt = 0.0
class Engine:
def __init__(self):
self.config = Configuration()
class Transform2d():
"""Mandatory Component attached to the GameObject containing all the geometric important data of the GameObject"""
def __init__(self):
self.position = Vector2f()
self.scale = Vector2f()
self.euler_angle = 0.0
class Sound:
def play(self):
pass
def stop(self):
pass
class Body2d:
def __init__(self):
self.velocity = p2Vec2()
self.magnitude = 0.0
self.position = p2Vec2()
def apply_force(self, force:p2Vec2):
pass
def set_position(self, position:p2Vec2):
pass
class Collider:
pass
class KeyboardManager:
class Key:
Space = 0
Up = 0
Down = 0
Left = 0
Right = 0
def is_key_held(self, key):
pass
def is_key_down(self, key):
pass
def is_key_up(self, key):
pass
class MouseManager:
def __init__(self):
self.position = Vec2f()
class InputManager:
keyboard = KeyboardManager()
mouse = MouseManager()
class Component:
Sprite = 0
Shape = 0
Body2d = 0
Sound = 0
Transform2d = 0
engine = Engine()
input_manager = InputManager()
scene_manager = SceneManager()
transform2d_manager = Transform2dManager()
entity_manager = EntityManager()
physics2d_manager = Physics2dManager()
# body2d_manager = Body2dManager() # Use physics2d_manager.body2d_manager instead.
graphics2d_manager = Graphics2dManager()
python_engine = PythonEngine()