2021-03-16 18:53:26 +01:00
|
|
|
import pygame
|
2021-05-18 19:34:52 +02:00
|
|
|
from Constants import ROWS, COLS, UP, LEFT, DOWN, RIGHT, DETONATE, DEFUSE, POLIGON
|
2021-03-30 21:01:54 +02:00
|
|
|
|
|
|
|
|
2021-03-15 19:04:51 +01:00
|
|
|
class Agent(object):
|
2021-03-27 22:07:55 +01:00
|
|
|
def __init__(self, point):
|
|
|
|
self.point = point
|
2021-03-16 18:53:26 +01:00
|
|
|
self.image = pygame.image.load('Engine/agent.png')
|
2021-04-27 21:10:01 +02:00
|
|
|
self.orientation = RIGHT
|
2021-03-15 19:04:51 +01:00
|
|
|
|
2021-03-27 22:07:55 +01:00
|
|
|
def getPoint(self):
|
|
|
|
return self.point
|
|
|
|
|
2021-03-30 21:01:54 +02:00
|
|
|
def defuse(self, bomb):
|
|
|
|
bomb.isDefused = True
|
|
|
|
|
2021-04-27 21:10:01 +02:00
|
|
|
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
|
|
|
|
|
2021-05-18 19:34:52 +02:00
|
|
|
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')
|
2021-04-27 21:10:01 +02:00
|
|
|
|
2021-04-13 19:32:08 +02:00
|
|
|
|
2021-03-16 18:53:26 +01:00
|
|
|
# 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
|
2021-03-30 21:01:54 +02:00
|
|
|
# return True
|