Merge branch 'master' of s450026/Sztuczna_Inteligencja_2020 into master
This commit is contained in:
commit
f5e3999fd8
BIN
resources/images/floor.jpg
Normal file
BIN
resources/images/floor.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.4 KiB |
BIN
resources/images/table.png
Normal file
BIN
resources/images/table.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
resources/images/waiter.png
Normal file
BIN
resources/images/waiter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
59
src/main.py
59
src/main.py
@ -1,28 +1,71 @@
|
|||||||
import sys
|
import sys
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
||||||
pygame.init()
|
pygame.init()
|
||||||
screen = pygame.display.set_mode((700, 750))
|
screen = pygame.display.set_mode((700, 750))
|
||||||
done = False
|
done = False
|
||||||
block_size = 50
|
block_size = 50
|
||||||
WHITE = (255, 255, 255)
|
clock = pygame.time.Clock()
|
||||||
BLUE = (0, 0, 255)
|
fps = 40
|
||||||
screen.fill(WHITE)
|
ani = 40
|
||||||
|
rect = 1
|
||||||
|
|
||||||
|
floor = pygame.image.load('../resources/images/floor.jpg')
|
||||||
|
table = pygame.image.load('../resources/images/table.png')
|
||||||
|
waiter = pygame.image.load('../resources/images/waiter.png')
|
||||||
|
|
||||||
|
|
||||||
|
def drawBackground():
|
||||||
|
for y in range(15):
|
||||||
|
for x in range(14):
|
||||||
|
# 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():
|
def main():
|
||||||
for y in range(15):
|
drawBackground()
|
||||||
for x in range(14):
|
|
||||||
rect = pygame.Rect(x * block_size, y * block_size, block_size - 1, block_size - 1)
|
|
||||||
pygame.draw.rect(screen, BLUE, rect)
|
|
||||||
|
|
||||||
while not done:
|
while not done:
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
pygame.quit()
|
pygame.quit()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
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()
|
||||||
pygame.display.update()
|
pygame.display.update()
|
||||||
|
clock.tick(fps)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user