import pygame class World: world_data = [ [1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ] # it will be changed when miguel sends his code def __init__(self, tile_size): self.tile_list = [] self.dirt_image = pygame.image.load('assets/images/dirt.jpeg') self.gravel_image = pygame.image.load('assets/images/gravel.jpeg') row_count = 0 for row in self.world_data: col_count = 0 for tile in row: if tile == 1: img = pygame.transform.scale(self.dirt_image, (tile_size, tile_size)) elif tile == 0: img = pygame.transform.scale(self.gravel_image, (tile_size, tile_size)) img_rect = img.get_rect() img_rect.x = col_count * tile_size img_rect.y = row_count * tile_size tile = (img, img_rect) self.tile_list.append(tile) col_count += 1 row_count += 1 def draw(self, screen): for tile in self.tile_list: screen.blit(tile[0], tile[1])