-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine_zepelim.py
69 lines (57 loc) · 1.97 KB
/
engine_zepelim.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
"""
EnGeni de Fisica
Sobrescreve o - PhysicsEngineSimple - do arcade
para resolver o bug de movimentação na parede
"""
import arcade.physics_engines
import copy
from arcade.geometry import check_for_collision_with_list
from arcade.geometry import check_for_collision
from arcade.sprite import Sprite
from arcade.sprite_list import SpriteList
class Zepelim(arcade.physics_engines.PhysicsEngineSimple):
"""
Essa classe move tudo e cuidar das colisões.
"""
def __init__(self, player_sprite: Sprite, walls: SpriteList):
"""
Constructor.
"""
assert(isinstance(player_sprite, Sprite))
assert(isinstance(walls, SpriteList))
self.player_sprite = player_sprite
self.walls = walls
def update(self):
"""
Move os objetos, verifica e resolve as colisões.
"""
player_aux = copy.deepcopy(self.player_sprite)
"""
Movimentação do eixo X
"""
player_aux.center_x += player_aux.change_x
# Check for wall hit
hit_list = \
check_for_collision_with_list(player_aux,
self.walls)
# If we hit a wall, move so the edges are at the same point
if len(hit_list) > 0:
self.player_sprite.change_x = 0
else:
self.player_sprite.center_x += self.player_sprite.change_x
"""
Movimentação do eixo Y
"""
player_aux.center_y += player_aux.change_y
# Check for wall hit
hit_list = \
check_for_collision_with_list(player_aux,
self.walls)
# If we hit a wall, move so the edges are at the same point
if len(hit_list) > 0:
self.player_sprite.change_y = 0
else:
self.player_sprite.center_y += self.player_sprite.change_y
#Limpeza de variaveis
self.player_sprite.change_x = 0
self.player_sprite.change_y = 0