Sztuczna_Inteligencja/waiter.py

36 lines
1.1 KiB
Python
Raw Normal View History

2019-03-19 23:36:06 +01:00
import pygame
from pygame.math import Vector2
class Waiter(object):
2019-03-20 23:46:50 +01:00
def __init__(self, game, x, y):
2019-03-19 23:36:06 +01:00
self.game = game
2019-03-20 23:46:50 +01:00
game.idItem += 1
2019-03-19 23:36:06 +01:00
self.size= self.game.screen.get_size()
2019-03-20 23:46:50 +01:00
self.x = x
self.y = y
2019-03-19 23:36:06 +01:00
self.image = pygame.image.load("./Images/w1.png").convert()
self.image.set_colorkey((255, 255, 255))
2019-03-20 23:46:50 +01:00
self.type = "waiter"
self.numberInGrid = game.idItem
2019-03-19 23:36:06 +01:00
def changePosition(self, vector):
self.position += vector
2019-03-20 23:46:50 +01:00
def move(self, game):
2019-03-19 23:36:06 +01:00
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
2019-03-20 23:46:50 +01:00
tmp = game.grid[game.waiterNumberInGrid-1]
tmp.x = tmp.x+50
game.grid[game.waiterNumberInGrid-1] = game.grid[game.waiterNumberInGrid]
game.grid[game.waiterNumberInGrid-1].x -= 50
game.grid[game.waiterNumberInGrid] = tmp
game.waiterNumberInGrid -= 1
2019-03-19 23:36:06 +01:00
def draw(self):
2019-03-20 23:46:50 +01:00
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
2019-03-20 20:42:55 +01:00
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
2019-03-20 23:46:50 +01:00
self.game.screen.blit(self.image, (self.x-50, self.y))