-
Notifications
You must be signed in to change notification settings - Fork 4
/
move.py
42 lines (34 loc) · 1.2 KB
/
move.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
# -*- coding: utf-8 -*-
import consts
class move:
@staticmethod
def getNextPosition(character, movePattern):
if movePattern['type'] == 'rect':
move.getNextPositionRect(character, movePattern['attributes'])
elif movePattern['type'] == 'circle':
pass
else:
raise move.exception('Unknown move')
@staticmethod
def getNextPositionRect(character, attributes):
xInMove = character.xPos - attributes['topLeft'][0]
yInMove = character.yPos - attributes['topLeft'][1]
if xInMove <= 0 and yInMove <= 0:
character.stop()
#~ move right
character.moveHorizontal(1)
elif xInMove >= attributes['width'] and yInMove <= 0:
character.stop()
#~ move down
character.moveVertical(1)
elif xInMove >= attributes['width']\
and yInMove >= attributes['height']:
character.stop()
#~ move left
character.moveHorizontal(-1)
elif xInMove <= 0 and yInMove >= attributes['height']:
character.stop()
#~ move up
character.moveVertical(-1)
class exception(BaseException):
pass