automatyczny_kelner/src/obj/Object.py

48 lines
1.5 KiB
Python
Raw Normal View History

import pygame
class Object:
def __init__(self, agent_role, position, orientation, square_size, square_count):
self.agent_role = agent_role
self.position = position
self.orientation = orientation % 4
self.square_size = square_size
self.square_count = square_count
self.image = pygame.image.load(
'src/img/{0}.png'.format(self.agent_role))
self.image = pygame.transform.scale(
self.image, (self.square_size, self.square_size))
self.rect = pygame.Rect(position[0] * square_size,
position[1] * square_size,
square_size, square_size)
def change_role(self, new_role):
self.agent_role = new_role
self.image = pygame.image.load('src/img/{0}.png'.format(new_role))
self.image = pygame.transform.scale(
self.image, (self.square_size, self.square_size))
def get_angle(self):
'''
orientation = 0 -> up\n
orientation = 1 -> left\n
orientation = 2 -> down\n
orientation = 3 -> right\n
'''
return self.orientation * 90
def collide_test(self, obj) -> bool:
return False
def goal_test(self, waiter) -> bool:
return False
def blit(self, screen: pygame.Surface):
image = pygame.transform.rotate(self.image, self.get_angle())
self.rect.x = self.position[0] * self.square_size
self.rect.y = self.position[1] * self.square_size
screen.blit(image, self.rect)