-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMouse.py
39 lines (30 loc) · 806 Bytes
/
Mouse.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
import API
from Direction import Direction
class Mouse:
def __init__(self, x, y, d):
self.x = x
self.y = y
self.d = d
def getPosition(self):
return (self.x, self.y)
def getDirection(self):
return self.d
def turnLeft(self):
API.turnLeft()
self.d = self.d.turnLeft()
def turnRight(self):
API.turnRight()
self.d = self.d.turnRight()
def turnAround(self):
self.turnRight()
self.turnRight()
def moveForward(self):
API.moveForward()
if self.d == Direction.NORTH:
self.y += 1
if self.d == Direction.EAST:
self.x += 1
if self.d == Direction.SOUTH:
self.y -= 1
if self.d == Direction.WEST:
self.x -= 1