Matrix of objects (class Tile)

This commit is contained in:
s444427 2020-04-03 00:36:09 +02:00
parent 5eb280929d
commit 12ecd02a27

View File

@ -27,6 +27,12 @@ class Waiter(pygame.sprite.Sprite):
screen.blit(self.imageWaiter, (self.moveX * block_size, self.moveY * block_size))
# TILE
class Tile:
x_position = 0
y_position = 0
# SETUP
pygame.init()
screen = pygame.display.set_mode((700, 750))
@ -40,6 +46,7 @@ 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')
matrix = []
def drawBackground():
@ -48,11 +55,23 @@ def drawBackground():
screen.blit(floor, (x * block_size, y * block_size))
def matrix_creator():
for y in range(15):
matrix.append([0] * 14)
for y in range(15):
for x in range(14):
matrix[y][x] = Tile()
matrix[y][x].x_position = x
matrix[y][x].y_position = y
waiterPly = Waiter()
def main():
drawBackground()
matrix_creator()
while not done:
for event in pygame.event.get():