{"id":138,"date":"2026-03-13T15:31:29","date_gmt":"2026-03-13T15:31:29","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/d_harkless\/?p=138"},"modified":"2026-03-13T15:31:29","modified_gmt":"2026-03-13T15:31:29","slug":"free-friday-3-13-26","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/d_harkless\/2026\/03\/13\/free-friday-3-13-26\/","title":{"rendered":"Free Friday 3\/13\/26"},"content":{"rendered":"\n<p>Today in class, I started making a tetris game.<\/p>\n\n\n\n<p>This is the code for the display surface<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>screen = pygame.display.set_mode((300, 600)) \npygame.display.set_caption(\"Python Tetris\")<\/code><\/pre>\n\n\n\n<p>This is the code for the grid.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Grid:\n    def __init__(self):\n        self.num_rows = 20\n        self.num_cols = 10\n        self.cell_size = 30\n        self.grid = &#91;&#91;0 for j in range(self.num_cols)] for i in range(self.num_rows)]\n        self.colors = Colors.get_cell_colors()\n\n    def print_grid(self):\n        for row in range(self.num_rows):\n            for column in range(self.num_cols):\n                print(self.grid&#91;row]&#91;column], end = \" \")\n            print()        \n    \n   \n    \n    def draw(self, screen):\n        for row in range(self.num_rows):\n            for column in range(self.num_cols):\n                cell_value = self.grid&#91;row]&#91;column]\n                cell_rect = pygame.Rect(column*self.cell_size +1, row*self.cell_size +1,\n                self.cell_size -1, self.cell_size -1)\n                pygame.draw.rect(screen, self.colors&#91;cell_value], cell_rect)<\/code><\/pre>\n\n\n\n<p>I started making the blocks, but I had a error in the colors.<\/p>\n\n\n\n<p>This is the code for the colors.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Colors:\n    dark_grey = (26, 31, 40)\n    green = (47, 230, 23)\n    red = (232, 18, 18)\n    orange = (226, 116, 17)\n    yellow = (237, 234, 4)\n    purple = (166, 0, 247)\n    cyan = (21, 204, 209)\n    blue = (13, 64, 216)\n@classmethod\ndef get_cell_colors(cls):\n    return &#91;cls.dark_grey, cls.green, cls.red, cls.orange, cls.yellow, cls.purple, cls.cyan, cls.blue]\n\nThis is the code for the blocks.<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>class LBlock (Block):\n    def __init__(self):\n        super().__init__(id = 1)\n        self.cells = {\n            0: &#91;Position(0, 2), Position(1, 0), Position(1, 1), Position(1, 2),],\n            1: &#91;Position(0, 1), Position(1, 1), Position(2, 1), Position(2, 2),],\n            2: &#91;Position(1, 0), Position(1, 1), Position(1, 2), Position(2, 0),],\n            3: &#91;Position(0, 0), Position(0, 1), Position(1, 1), Position(2, 1),]\n        }<\/code><\/pre>\n\n\n\n<p>Link:<a href=\"https:\/\/www.youtube.com\/watch?v=nF_crEtmpBo\">https:\/\/www.youtube.com\/watch?v=nF_crEtmpBo<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"963\" height=\"612\" src=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/03\/image-4.png\" alt=\"\" class=\"wp-image-139\" style=\"aspect-ratio:1.5735401726913507;width:670px;height:auto\" srcset=\"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/03\/image-4.png 963w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/03\/image-4-300x191.png 300w, https:\/\/theroyalscode.com\/students\/d_harkless\/wp-content\/uploads\/2026\/03\/image-4-768x488.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today in class, I started making a tetris game. This is the code for the display surface This is the code for the grid. I started making the blocks, but I had a error in the colors. This is the code for the colors. Link:https:\/\/www.youtube.com\/watch?v=nF_crEtmpBo<\/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-138","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/comments?post=138"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/138\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/posts\/138\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/media?parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/categories?post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/d_harkless\/wp-json\/wp\/v2\/tags?post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}