{"id":69,"date":"2025-04-04T13:51:20","date_gmt":"2025-04-04T13:51:20","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/l_rankins\/?p=69"},"modified":"2025-04-04T13:51:20","modified_gmt":"2025-04-04T13:51:20","slug":"blog-6-maddness","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/l_rankins\/2025\/04\/04\/blog-6-maddness\/","title":{"rendered":"BLOG 6: MADDNESS"},"content":{"rendered":"\n<p>i made a level editor for my platformer <\/p>\n\n\n\n<p>import pygame<\/p>\n\n\n\n<p>import pickle<\/p>\n\n\n\n<p>from os import path<\/p>\n\n\n\n<p>pygame.init()<\/p>\n\n\n\n<p>clock = pygame.time.Clock()<\/p>\n\n\n\n<p>fps = 60<\/p>\n\n\n\n<p>#game window<\/p>\n\n\n\n<p>tile_size = 50<\/p>\n\n\n\n<p>cols = 20<\/p>\n\n\n\n<p>margin = 100<\/p>\n\n\n\n<p>screen_width = tile_size * cols<\/p>\n\n\n\n<p>screen_height = (tile_size * cols) + margin<\/p>\n\n\n\n<p>screen = pygame.display.set_mode((screen_width, screen_height))<\/p>\n\n\n\n<p>pygame.display.set_caption(&#8216;Level Editor&#8217;)<\/p>\n\n\n\n<p>#load images<\/p>\n\n\n\n<p>sun_img = pygame.image.load(&#8216;img\/sun.png&#8217;)<\/p>\n\n\n\n<p>sun_img = pygame.transform.scale(sun_img, (tile_size, tile_size))<\/p>\n\n\n\n<p>bg_img = pygame.image.load(&#8216;img\/sky.png&#8217;)<\/p>\n\n\n\n<p>bg_img = pygame.transform.scale(bg_img, (screen_width, screen_height &#8211; margin))<\/p>\n\n\n\n<p>dirt_img = pygame.image.load(&#8216;img\/dirt.png&#8217;)<\/p>\n\n\n\n<p>grass_img = pygame.image.load(&#8216;img\/grass.png&#8217;)<\/p>\n\n\n\n<p>blob_img = pygame.image.load(&#8216;img\/blob.png&#8217;)<\/p>\n\n\n\n<p>platform_x_img = pygame.image.load(&#8216;img\/platform_x.png&#8217;)<\/p>\n\n\n\n<p>platform_y_img = pygame.image.load(&#8216;img\/platform_y.png&#8217;)<\/p>\n\n\n\n<p>lava_img = pygame.image.load(&#8216;img\/lava.png&#8217;)<\/p>\n\n\n\n<p>coin_img = pygame.image.load(&#8216;img\/coin.png&#8217;)<\/p>\n\n\n\n<p>exit_img = pygame.image.load(&#8216;img\/exit.png&#8217;)<\/p>\n\n\n\n<p>save_img = pygame.image.load(&#8216;img\/save_btn.png&#8217;)<\/p>\n\n\n\n<p>load_img = pygame.image.load(&#8216;img\/load_btn.png&#8217;)<\/p>\n\n\n\n<p>#define game variables<\/p>\n\n\n\n<p>clicked = False<\/p>\n\n\n\n<p>level = 1<\/p>\n\n\n\n<p>#define colours<\/p>\n\n\n\n<p>white = (255, 255, 255)<\/p>\n\n\n\n<p>green = (144, 201, 120)<\/p>\n\n\n\n<p>font = pygame.font.SysFont(&#8216;Futura&#8217;, 24)<\/p>\n\n\n\n<p>#create empty tile list<\/p>\n\n\n\n<p>world_data = []<\/p>\n\n\n\n<p>for row in range(20):<\/p>\n\n\n\n<p>&nbsp; &nbsp; r = [0] * 20<\/p>\n\n\n\n<p>&nbsp; &nbsp; world_data.append(r)<\/p>\n\n\n\n<p>#create boundary<\/p>\n\n\n\n<p>for tile in range(0, 20):<\/p>\n\n\n\n<p>&nbsp; &nbsp; world_data[19][tile] = 2<\/p>\n\n\n\n<p>&nbsp; &nbsp; world_data[0][tile] = 1<\/p>\n\n\n\n<p>&nbsp; &nbsp; world_data[tile][0] = 1<\/p>\n\n\n\n<p>&nbsp; &nbsp; world_data[tile][19] = 1<\/p>\n\n\n\n<p>#function for outputting text onto the screen<\/p>\n\n\n\n<p><em>def<\/em> draw_text(<em>text<\/em>, <em>font<\/em>, <em>text_col<\/em>, <em>x<\/em>, <em>y<\/em>):<\/p>\n\n\n\n<p>&nbsp; &nbsp; img = <em>font<\/em>.render(<em>text<\/em>, True, <em>text_col<\/em>)<\/p>\n\n\n\n<p>&nbsp; &nbsp; screen.blit(img, (<em>x<\/em>, <em>y<\/em>))<\/p>\n\n\n\n<p><em>def<\/em> draw_grid():<\/p>\n\n\n\n<p>&nbsp; &nbsp; for c in range(21):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #vertical lines<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; pygame.draw.line(screen, white, (c * tile_size, 0), (c * tile_size, screen_height &#8211; margin))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #horizontal lines<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; pygame.draw.line(screen, white, (0, c * tile_size), (screen_width, c * tile_size))<\/p>\n\n\n\n<p><em>def<\/em> draw_world():<\/p>\n\n\n\n<p>&nbsp; &nbsp; for row in range(20):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; for col in range(20):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] &gt; 0:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 1:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #dirt blocks<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(dirt_img, (tile_size, tile_size))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 2:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #grass blocks<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(grass_img, (tile_size, tile_size))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 3:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #enemy blocks<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(blob_img, (tile_size, int(tile_size * 0.75)))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size + (tile_size * 0.25)))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 4:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #horizontally moving platform<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(platform_x_img, (tile_size, tile_size \/\/ 2))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 5:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #vertically moving platform<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(platform_y_img, (tile_size, tile_size \/\/ 2))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 6:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #lava<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(lava_img, (tile_size, tile_size \/\/ 2))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size + (tile_size \/\/ 2)))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 7:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #coin<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(coin_img, (tile_size \/\/ 2, tile_size \/\/ 2))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size + (tile_size \/\/ 4), row * tile_size + (tile_size \/\/ 4)))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[row][col] == 8:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #exit<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; img = pygame.transform.scale(exit_img, (tile_size, int(tile_size * 1.5)))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; screen.blit(img, (col * tile_size, row * tile_size &#8211; (tile_size \/\/ 2)))<\/p>\n\n\n\n<p><em>class<\/em> Button():<\/p>\n\n\n\n<p>&nbsp; &nbsp; <em>def<\/em> __init__(<em>self<\/em>, <em>x<\/em>, <em>y<\/em>, <em>image<\/em>):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; <em>self<\/em>.image = <em>image<\/em><\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; <em>self<\/em>.rect = <em>self<\/em>.image.get_rect()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; <em>self<\/em>.rect.topleft = (<em>x<\/em>, <em>y<\/em>)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; <em>self<\/em>.clicked = False<\/p>\n\n\n\n<p>&nbsp; &nbsp; <em>def<\/em> draw(<em>self<\/em>):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; action = False<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #get mouse position<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; pos = pygame.mouse.get_pos()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #check mouseover and clicked conditions<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if <em>self<\/em>.rect.collidepoint(pos):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if pygame.mouse.get_pressed()[0] == 1 and <em>self<\/em>.clicked == False:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; action = True<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <em>self<\/em>.clicked = True<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if pygame.mouse.get_pressed()[0] == 0:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <em>self<\/em>.clicked = False<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #draw button<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; screen.blit(<em>self<\/em>.image, (<em>self<\/em>.rect.x, <em>self<\/em>.rect.y))<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; return action<\/p>\n\n\n\n<p>#create load and save buttons<\/p>\n\n\n\n<p>save_button = Button(screen_width \/\/ 2 &#8211; 150, screen_height &#8211; 80, save_img)<\/p>\n\n\n\n<p>load_button = Button(screen_width \/\/ 2 + 50, screen_height &#8211; 80, load_img)<\/p>\n\n\n\n<p>#main game loop<\/p>\n\n\n\n<p>run = True<\/p>\n\n\n\n<p>while run:<\/p>\n\n\n\n<p>&nbsp; &nbsp; clock.tick(fps)<\/p>\n\n\n\n<p>&nbsp; &nbsp; #draw background<\/p>\n\n\n\n<p>&nbsp; &nbsp; screen.fill(green)<\/p>\n\n\n\n<p>&nbsp; &nbsp; screen.blit(bg_img, (0, 0))<\/p>\n\n\n\n<p>&nbsp; &nbsp; screen.blit(sun_img, (tile_size * 2, tile_size * 2))<\/p>\n\n\n\n<p>&nbsp; &nbsp; #load and save level<\/p>\n\n\n\n<p>&nbsp; &nbsp; if save_button.draw():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #save level data<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; pickle_out = open(<em>f<\/em>&#8216;level{level}_data&#8217;, &#8216;wb&#8217;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; pickle.dump(world_data, pickle_out)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; pickle_out.close()<\/p>\n\n\n\n<p>&nbsp; &nbsp; if load_button.draw():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #load in level data<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if path.exists(<em>f<\/em>&#8216;level{level}_data&#8217;):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pickle_in = open(<em>f<\/em>&#8216;level{level}_data&#8217;, &#8216;rb&#8217;)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; world_data = pickle.load(pickle_in)<\/p>\n\n\n\n<p>&nbsp; &nbsp; #show the grid and draw the level tiles<\/p>\n\n\n\n<p>&nbsp; &nbsp; draw_grid()<\/p>\n\n\n\n<p>&nbsp; &nbsp; draw_world()<\/p>\n\n\n\n<p>&nbsp; &nbsp; #text showing current level<\/p>\n\n\n\n<p>&nbsp; &nbsp; draw_text(<em>f<\/em>&#8216;Level: {level}&#8217;, font, white, tile_size, screen_height &#8211; 60)<\/p>\n\n\n\n<p>&nbsp; &nbsp; draw_text(&#8216;Press UP or DOWN to change level&#8217;, font, white, tile_size, screen_height &#8211; 40)<\/p>\n\n\n\n<p>&nbsp; &nbsp; #event handler<\/p>\n\n\n\n<p>&nbsp; &nbsp; for event in pygame.event.get():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #quit game<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.QUIT:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run = False<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #mouseclicks to change tiles<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.MOUSEBUTTONDOWN and clicked == False:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clicked = True<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos = pygame.mouse.get_pos()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = pos[0] \/\/ tile_size<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = pos[1] \/\/ tile_size<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #check that the coordinates are within the tile area<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if x &lt; 20 and y &lt; 20:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #update tile value<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if pygame.mouse.get_pressed()[0] == 1:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; world_data[y][x] += 1<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[y][x] &gt; 8:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; world_data[y][x] = 0<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif pygame.mouse.get_pressed()[2] == 1:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; world_data[y][x] -= 1<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if world_data[y][x] &lt; 0:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; world_data[y][x] = 8<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.MOUSEBUTTONUP:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clicked = False<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; #up and down key presses to change level number<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; if event.type == pygame.KEYDOWN:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if event.key == pygame.K_UP:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; level += 1<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elif event.key == pygame.K_DOWN and level &gt; 1:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; level -= 1<\/p>\n\n\n\n<p>&nbsp; &nbsp; #update game display window<\/p>\n\n\n\n<p>&nbsp; &nbsp; pygame.display.update()<\/p>\n\n\n\n<p>pygame.quit()<\/p>\n","protected":false},"excerpt":{"rendered":"<p>i made a level editor for my platformer import pygame import pickle from os import path pygame.init() clock = pygame.time.Clock() [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":70,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/posts\/69\/revisions\/70"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/l_rankins\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}