import pygame import button import csv import pickle pygame.init() clock = pygame.time.Clock() FPS = 60 #game window SCREEN_WIDTH = 800 SCREEN_HEIGHT = 640 LOWER_MARGIN = 100 SIDE_MARGIN = 300 screen = pygame.display.set_mode((SCREEN_WIDTH + SIDE_MARGIN, SCREEN_HEIGHT + LOWER_MARGIN)) pygame.display.set_caption('Level Editor') #define game variables ROWS = 16 MAX_COLS = 150 TILE_SIZE = SCREEN_HEIGHT // ROWS TILE_TYPES = 21 level = 0 current_tile = 0 scroll_left = False scroll_right = False scroll = 0 scroll_speed = 1 #load images pine1_img = pygame.image.load('Mini Project 1/img/Background/pine1.png').convert_alpha pine2_img = pygame.image.load('Mini Project 1/img/Background/pine2.png').convert_alpha mountain_img = pygame.image.load('Mini Project 1/img/Background/mountain.png').convert_alpha sky_img = pygame.image.load('Mini Project 1/img/Background/sky_cloud.png').convert_alpha #store tiles in a list img_list = [] for x in range (TILE_TYPES): img = pygame.load(f'Mini Project 1/img/tile/{x}.png').convert_alpha() img = pygame.transform.scale(img, (TILE_SIZE, TILE_SIZE)) img_list.append(img) save_img = pygame.image.load('Mini Project 1/img/save_btn.png').convert_alpha load_img = pygame.image.load('Mini Project 1/img/load_btn.png').convert_alpha #define colours GREEN = (144, 201, 120) WHITE = (255, 255, 255) RED = (200, 25, 25) #define font font = pygame.font.SysFont('Futura', 30) #create empty tile list world_data = [] for row in range(ROWS): r = [-1] * MAX_COLS world_data.append(r) #create ground for tile in range(0, MAX_COLS): world_data[ROWS - 1][tile] = 0 #function for outputting text on screen def draw_text(text,font,text_col,x,y): img = font.render(text, True, text_col) screen.blit(img, (x,y)) #create function for drawing background def draw_bg(): screen.fill(GREEN) width = sky_img.get_width() for x in range(4): screen.blit(sky_img, ((x * width) - scroll))