{"id":148,"date":"2026-03-24T14:25:11","date_gmt":"2026-03-24T14:25:11","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/d_eanes\/?p=148"},"modified":"2026-03-24T14:25:11","modified_gmt":"2026-03-24T14:25:11","slug":"free-friday-3-20-2026","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/d_eanes\/2026\/03\/24\/free-friday-3-20-2026\/","title":{"rendered":"Free Friday: 3\/20\/2026"},"content":{"rendered":"\n<p> <\/p>\n\n\n\n<p>Today I worked on a Python version of the classic 2048 game using Pygame. The whole thing runs in an 800\u00d7800 window, split into a 4\u00d74 grid. Tiles slide around, merge when they match, and new tiles spawn after every move just like the real game.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Tile:<\/code><\/pre>\n\n\n\n<p>^This class handles everything about the individual tiles. Each tile knows its value, its position on the grid, and its pixel coordinates. It also picks a color based on its value and draws itself with centered text. The tile can move smoothly across the board and update its row\/column once it lands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def draw_grid(window):<\/code><\/pre>\n\n\n\n<p>^This draws the thick grid lines that separate the 16 squares. It\u2019s just visual structure no gameplay logic here.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def draw(window, tiles):<\/code><\/pre>\n\n\n\n<p>^This function clears the screen, draws every tile, draws the grid, and updates the display. It\u2019s the main \u201crender everything\u201d function that gets called every frame.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def get_random_pos(tiles):<\/code><\/pre>\n\n\n\n<p>^This picks a random empty spot on the board. It keeps generating row\/column pairs until it finds one that isn\u2019t already occupied by a tile. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"797\" height=\"827\" src=\"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-100213.png\" alt=\"\" class=\"wp-image-150\" srcset=\"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-100213.png 797w, https:\/\/theroyalscode.com\/students\/d_eanes\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-100213-289x300.png 289w, https:\/\/theroyalscode.com\/students\/d_eanes\/wp-content\/uploads\/2026\/03\/Screenshot-2026-03-24-100213-768x797.png 768w\" sizes=\"auto, (max-width: 797px) 100vw, 797px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Today I worked on a Python version of the classic 2048 game using Pygame. The whole thing runs in an 800\u00d7800 window, split into a 4\u00d74 grid. Tiles slide around, merge when they match, and new tiles spawn after every move just like the real game. ^This class handles everything about the individual tiles. Each&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-148","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts\/148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":151,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/posts\/148\/revisions\/151"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_eanes\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}