{"id":54,"date":"2025-11-14T15:07:18","date_gmt":"2025-11-14T15:07:18","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/c_menhart\/?p=54"},"modified":"2025-11-14T15:07:18","modified_gmt":"2025-11-14T15:07:18","slug":"i-messed-up-and-wanted-to-make-it-but-i-didnt-make-it-work","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/c_menhart\/2025\/11\/14\/i-messed-up-and-wanted-to-make-it-but-i-didnt-make-it-work\/","title":{"rendered":"i messed up and wanted to make it but i didn&#8217;t make it work"},"content":{"rendered":"\n<p>import sys, pygame, random<\/p>\n\n\n\n<p>pygame.init()<\/p>\n\n\n\n<p>WIDTH, HEIGHT = 800, 600<\/p>\n\n\n\n<p>GRID_SIZE = 25<\/p>\n\n\n\n<p>WHITE = (255, 255, 255)<\/p>\n\n\n\n<p>BLACK = (0, 0, 0)<\/p>\n\n\n\n<p>COLORS = [(255,0,0), (0,255,0), (0,0,255)]<\/p>\n\n\n\n<p>SHAPES = [<\/p>\n\n\n\n<p>&nbsp; &nbsp;[[&#8216;&#8230;..&#8217;,&#8217;&#8230;..&#8217;,&#8217;&#8230;..&#8217;,&#8217;OOOO.&#8217;,&#8217;&#8230;..&#8217;],<\/p>\n\n\n\n<p>&nbsp; &nbsp; [&#8216;..O..&#8217;,&#8217;..O..&#8217;,&#8217;..O..&#8217;,&#8217;..O..&#8217;,&#8217;&#8230;..&#8217;]],<\/p>\n\n\n\n<p>&nbsp; &nbsp;[[&#8216;&#8230;..&#8217;,&#8217;..O..&#8217;,&#8217;.OOO.&#8217;,&#8217;&#8230;..&#8217;,&#8217;&#8230;..&#8217;]]<\/p>\n\n\n\n<p>]<\/p>\n\n\n\n<p>class Tetromino:<\/p>\n\n\n\n<p>&nbsp; &nbsp;def __init__(self, x, y, shape):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;self.x = x<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;self.y = y<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;self.shape = shape<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;self.color = random.choice(COLORS)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;self.rotation = 0<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;class Tetris:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; def __init__(self, width, height):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self.width = width<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; self.height = height<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; self.grid = [[0]*width for _ in range(height)]<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; self.current_piece = self.new_piece()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; self.score = 0<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; self.game_over = False<\/p>\n\n\n\n<p>&nbsp; &nbsp;def new_piece(self):<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;return Tetromino(self.width\/\/2, 0, random.choice(SHAPES))<\/p>\n\n\n\n<p>&nbsp; &nbsp;def main():<\/p>\n\n\n\n<p>&nbsp; &nbsp; screen = pygame.display.set_mode((WIDTH, HEIGHT))<\/p>\n\n\n\n<p>&nbsp; &nbsp;clock = pygame.time.Clock()<\/p>\n\n\n\n<p>&nbsp; &nbsp;game = Tetris(WIDTH\/\/GRID_SIZE, HEIGHT\/\/GRID_SIZE)<\/p>\n\n\n\n<p>&nbsp; &nbsp;while True:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;screen.fill(BLACK)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;for event in pygame.event.get():<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.QUIT:<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pygame.quit(); sys.exit()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;game.update()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;game.draw(screen)<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;pygame.display.flip()<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp;clock.tick(60)<\/p>\n\n\n\n<p>main()<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import sys, pygame, random pygame.init() WIDTH, HEIGHT = 800, 600 GRID_SIZE = 25 WHITE = (255, 255, 255) BLACK = [&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":"default","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-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":"","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-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":"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":""},"mobile":{"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":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":55,"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/posts\/54\/revisions\/55"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/c_menhart\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}