import pygame from pygame.locals import * # 17:32 pygame.init() screen_width = 1000 screen_height = 1000 screen = pygame.display.set_mode((screen_width, screen_height)) pygame.display.set_caption('Platformer') tile_size = 200 #image loader sun_img = pygame.image.load('target.png') bg_img = pygame.image.load('BG.png') 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 = [] #image loader dirt_img = pygame.image.load('crosshair.png') 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 def draw(self): 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(bg_img, (0, 0)) screen.blit(sun_img, (100, 100)) draw_grid() for event in pygame.event.get(): if event.type == pygame.QUIT: run = False pygame.display.update() pygame.quit()