Projekt_AI-Automatyczny_saper/Engine/Agent.py
2021-05-18 19:34:52 +02:00

53 lines
1.6 KiB
Python

import pygame
from Constants import ROWS, COLS, UP, LEFT, DOWN, RIGHT, DETONATE, DEFUSE, POLIGON
class Agent(object):
def __init__(self, point):
self.point = point
self.image = pygame.image.load('Engine/agent.png')
self.orientation = RIGHT
def getPoint(self):
return self.point
def defuse(self, bomb):
bomb.isDefused = True
def rotateImage(self):
self.image = pygame.image.load('Engine/agent.png')
if self.orientation == LEFT:
self.image = pygame.transform.rotate(self.image, 180)
self.image = pygame.transform.flip(self.image, False, True)
elif self.orientation == DOWN:
self.image = pygame.transform.rotate(self.image, 270)
elif self.orientation == UP:
self.image = pygame.transform.rotate(self.image, 90)
def getOrientation(self):
return self.orientation
def changeImage(self, imageType):
if imageType == DETONATE:
self.image = pygame.image.load('Engine/' + DETONATE + '.png')
if imageType == DEFUSE:
self.image = pygame.image.load('Engine/' + DEFUSE + '.png')
self.image = pygame.image.load('Engine/agent.png')
# def ifNotOnEdge(self, destination):
# if destination == UP:
# if self.x - 1 <= 0:
# return False
# if destination == DOWN:
# if self.x + 1 > ROWS:
# return False
# if destination == LEFT:
# if self.y - 1 <= 0:
# return False
# if destination == RIGHT:
# if self.y + 1 > COLS:
# return False
# return True