Projekt_AI-Automatyczny_saper/Engine/Agent.py

61 lines
2.0 KiB
Python

import pygame
from Constants import ROWS, COLS, UP, LEFT, DOWN, RIGHT, DETONATE, DEFUSE, POLIGON, AGENT
class Agent(object):
def __init__(self, point):
self.point = point
self.image = pygame.image.load('Engine/agent.png')
self.orientation = RIGHT
self.state = 'agent'
def getPoint(self):
return self.point
def defuse(self, bomb):
bomb.isDefused = True
def rotateImage(self):
self.image = pygame.image.load('Engine/' + self.state + '.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.state = DETONATE
self.image = pygame.image.load('Engine/' + DETONATE + '.png')
if imageType == DEFUSE:
self.state = DEFUSE
self.image = pygame.image.load('Engine/' + DEFUSE + '.png')
if imageType == AGENT:
self.state = AGENT
self.image = pygame.image.load('Engine/' + AGENT + '.png')
if imageType == POLIGON:
self.state = POLIGON
self.image = pygame.image.load('Engine/' + POLIGON + '.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