import pygame from pygame.locals import * pygame.init() screen_width = 1000 screen_height = 1000 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption('Platformer') #load images sun_img = pygame.image.load("sun.png") bg_img = pygame.image.load('sky.png') bg2_img = pygame.image.load('sky1.png') #def game variables tile_size = 200 def draw_grid(): for line in range(0, 6): pygame.draw.line(screen, (255, 255, 255), (0, line * tile_size), (screen_width, line * tile_size)) pygame.draw.line(screen, (255, 255, 255), (line * tile_size, 0), (line * tile_size, screen_height)) class World(): def _init_(self, data): self.tile_list = [] #load images dirt_img = pygame.image.load('dirt_img.webp') row_count = 0 for row in data: col_count = 0 for tile in row: if tile == 1: img = pygame.transform.scale(dirt_img, (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 world_data = [ [1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], ] world = World(world_data) run = True while run: screen.blit(bg2_img, (0, 300)) screen.blit(bg_img, (0, 0)) screen.blit(sun_img, (0, 0)) draw_grid() for event in pygame.event.get(): if event.type == pygame.QUIT: run = False pygame.display.update() pygame.quit()