32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import pygame
|
|
from pygame.math import Vector2
|
|
|
|
class Waiter(object):
|
|
|
|
def __init__(self, game):
|
|
self.game = game
|
|
self.size= self.game.screen.get_size()
|
|
self.position = Vector2(self.size[0]-100,self.size[1]-200)
|
|
self.image = pygame.image.load("./Images/w1.png").convert()
|
|
self.image.set_colorkey((255, 255, 255))
|
|
|
|
def changePosition(self, vector):
|
|
self.position += vector
|
|
|
|
|
|
def move(self):
|
|
keys = pygame.key.get_pressed()
|
|
if keys[pygame.K_DOWN]:
|
|
self.changePosition(Vector2(0,50))
|
|
if keys[pygame.K_UP]:
|
|
self.changePosition(Vector2(0,-50))
|
|
if keys[pygame.K_RIGHT]:
|
|
self.changePosition(Vector2(50,0))
|
|
if keys[pygame.K_LEFT]:
|
|
self.changePosition(Vector2(-50,0))
|
|
|
|
def draw(self):
|
|
rect1 = pygame.Rect(self.position.x, self.position.y, 100, 200)
|
|
#pygame.draw.rect(self.game.screen, (0, 150, 255), rect1)
|
|
self.game.screen.blit(self.image, (self.position.x, self.position.y))
|