2020-03-23 20:55:52 +01:00
|
|
|
import sys
|
|
|
|
import pygame
|
|
|
|
|
2020-04-02 22:28:30 +02:00
|
|
|
|
|
|
|
# WAITER
|
|
|
|
class Waiter(pygame.sprite.Sprite):
|
|
|
|
def __init__(self):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.moveX = 0
|
|
|
|
self.moveY = 0
|
|
|
|
self.frame = 0
|
|
|
|
self.image = waiter
|
|
|
|
|
|
|
|
def move(self, x, y):
|
|
|
|
self.moveX += x
|
|
|
|
self.moveY -= y
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
screen.blit(floor, ())
|
|
|
|
screen.blit(waiter, (self.moveX * block_size, self.moveY * block_size))
|
|
|
|
|
|
|
|
|
|
|
|
# SETUP
|
2020-03-23 20:55:52 +01:00
|
|
|
pygame.init()
|
2020-04-02 20:37:21 +02:00
|
|
|
screen = pygame.display.set_mode((700, 750))
|
2020-03-23 20:55:52 +01:00
|
|
|
done = False
|
2020-04-02 20:37:21 +02:00
|
|
|
block_size = 50
|
2020-04-02 22:28:30 +02:00
|
|
|
clock = pygame.time.Clock()
|
|
|
|
fps = 40
|
|
|
|
ani = 40
|
|
|
|
rect = 1
|
2020-03-23 20:55:52 +01:00
|
|
|
|
2020-04-02 22:28:30 +02:00
|
|
|
floor = pygame.image.load('../resources/images/floor.jpg')
|
|
|
|
table = pygame.image.load('../resources/images/table.png')
|
|
|
|
waiter = pygame.image.load('../resources/images/waiter.png')
|
2020-03-23 20:55:52 +01:00
|
|
|
|
2020-04-02 22:28:30 +02:00
|
|
|
|
|
|
|
def drawBackground():
|
2020-04-02 20:37:21 +02:00
|
|
|
for y in range(15):
|
|
|
|
for x in range(14):
|
2020-04-02 22:28:30 +02:00
|
|
|
# rect = pygame.Rect(x * block_size, y * block_size, block_size - 1, block_size - 1)
|
|
|
|
# pygame.draw.rect(screen, floor, rect)
|
|
|
|
screen.blit(floor, (x * block_size, y * block_size))
|
|
|
|
|
|
|
|
|
|
|
|
waiterPly = Waiter()
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
drawBackground()
|
2020-03-23 20:55:52 +01:00
|
|
|
|
|
|
|
while not done:
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
pygame.quit()
|
|
|
|
sys.exit()
|
2020-04-02 22:28:30 +02:00
|
|
|
if event.type == pygame.KEYDOWN:
|
|
|
|
if event.key == pygame.K_LEFT:
|
|
|
|
waiterPly.move(-rect, 0)
|
|
|
|
if event.key == pygame.K_RIGHT:
|
|
|
|
waiterPly.move(rect, 0)
|
|
|
|
if event.key == pygame.K_UP:
|
|
|
|
waiterPly.move(0, rect)
|
|
|
|
if event.key == pygame.K_DOWN:
|
|
|
|
waiterPly.move(0, -rect)
|
|
|
|
waiterPly.update()
|
2020-03-23 20:55:52 +01:00
|
|
|
pygame.display.update()
|
2020-04-02 22:28:30 +02:00
|
|
|
clock.tick(fps)
|
2020-03-23 20:55:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
main()
|