-
Notifications
You must be signed in to change notification settings - Fork 1
/
MonsterEngine.py
101 lines (70 loc) · 2.44 KB
/
MonsterEngine.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
# -*- coding: utf-8 -*-
import random
__author__ = 'Yoann'
"""
Unité qui regroupe les différent moteur calculant le déplacement
d'un monstre.
prototype def <MonMonsterEngine> ( self, dt)
"""
def MME_Standard(self, dt):
"""
Déplacement basé sur une direction disponnible au hazard, si pas bon
prendre la direction par défaut
"""
directions = self.OnAvlDir(self.x,self.y)
hasMoved = False
# if self.lastDir in directions:
# directions.remove(self.lastDir)
# hasMoved = self.move(self.lastDir)
if directions == []:
return None
while(hasMoved == False):
a = random.choice(directions)
hasMoved = self.move(a)
if hasMoved == False:
directions.remove(a)
if self.lastDir in directions:
directions.remove(self.lastDir)
hasMoved = self.move(self.lastDir)
elif len(directions) == 0:
self.moveToInitialPos()
hasMoved = True
def MME_Foward(self, dt):
"""
Déplacement basé sur une direction disponnible au hazard, si pas bon
prendre la direction par défaut
"""
directions = self.OnAvlDir(self.x,self.y)
hasMoved = False
if self.lastDir in directions:
directions.remove(self.lastDir)
hasMoved = self.move(self.lastDir)
if directions == []:
return None
while(hasMoved == False):
a = random.choice(directions)
hasMoved = self.move(a)
if hasMoved == False:
directions.remove(a)
if self.lastDir in directions:
directions.remove(self.lastDir)
hasMoved = self.move(self.lastDir)
elif len(directions) == 0:
self.moveToInitialPos()
hasMoved = True
def MME_Basic(self,dt):
"""
Déplacement basé sur une direction disponnible au hazard
"""
directions = self.OnAvlDir(self.x,self.y)
hasMoved = False
if directions == []:
return None
while(hasMoved == False):
a = random.choice(directions)
hasMoved = self.move(a)
if hasMoved == False:
directions.remove(a)
if len(directions) == 0:
self.moveToInitialPos()
hasMoved = True