Sztuczna_inteligencja_gr_13/bin/classess/Player.py

56 lines
1.6 KiB
Python
Raw Normal View History

2021-04-02 03:39:46 +02:00
WINDOW_X = 533 + 1200
WINDOW_Y = 950
FRAME_WIDTH = 533
FRAME_HEIGHT = 533
# Size of small image
IMAGE_SIZE = 50
class Player(object):
def __init__(self):
self.x_start = 3
self.y_start = 3
self.current_x = self.x_start
self.current_y = self.y_start
self.step = IMAGE_SIZE + self.x_start
self.current_array_x = 0
self.current_array_y = 0
2021-04-24 03:05:17 +02:00
self.direction = "east"
self.directions = ["north", "east", "south", "west"]
self.arrow_north_image = None
self.arrow_south_image = None
self.arrow_west_image = None
self.arrow_east_image = None
2021-04-24 17:32:07 +02:00
self.image_canvas_id = None
2021-04-02 03:39:46 +02:00
2021-04-02 04:08:50 +02:00
def MovingRight(self):
if self.current_x + self.step < FRAME_WIDTH:
self.current_x += self.step
self.current_array_x += 1
2021-04-02 03:39:46 +02:00
2021-04-02 04:08:50 +02:00
def MovingLeft(self):
if self.current_x - self.step >= self.x_start:
self.current_x -= self.step
self.current_array_x -= 1
def MovingUp(self):
if self.current_y - self.step >= self.y_start:
self.current_y -= self.step
self.current_array_y -= 1
def MovingDown(self):
if self.current_y + self.step < FRAME_HEIGHT:
self.current_y += self.step
self.current_array_y += 1
2021-04-24 03:05:17 +02:00
def Moving(self):
if self.direction == "north":
self.MovingUp()
if self.direction == "south":
self.MovingDown()
if self.direction == "west":
self.MovingLeft()
if self.direction == "east":
self.MovingRight()