{"id":173,"date":"2026-10-09T14:09:09","date_gmt":"2026-10-09T14:09:09","guid":{"rendered":"https:\/\/theroyalscode.com\/students\/a_mehraban\/?p=173"},"modified":"2026-10-09T14:09:09","modified_gmt":"2026-10-09T14:09:09","slug":"free-friday-assigment-10-9-2026","status":"publish","type":"post","link":"https:\/\/theroyalscode.com\/students\/a_mehraban\/2026\/10\/09\/free-friday-assigment-10-9-2026\/","title":{"rendered":"Free friday assigment   10\/9\/2026"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">so i made a game named so i made a game named \u00a0Subway Surfer<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">here i will post all the code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pygame\n\npygame.init()\n\n# Constants\nWIDTH, HEIGHT = 800, 400\nGROUND_HEIGHT = 100\nFPS = 60\n\n# Colors\nWHITE = (255, 255, 255)\nBLACK = (0, 0, 0)\nRED = (255, 0, 0)\nBLUE = (0, 100, 255)\nGREEN = (50, 180, 50)\n\n# Create the game window\nscreen = pygame.display.set_mode((WIDTH, HEIGHT))\npygame.display.set_caption(\"Subway Surfers\")\nclock = pygame.time.Clock()\nfont = pygame.font.Font(None, 36)\n\n# Player rectangle\nplayer_width, player_height = 40, 60\nplayer_x = WIDTH \/\/ 2\nplayer_y = HEIGHT - GROUND_HEIGHT - player_height\nplayer_speed = 5\n\n# Jump settings\nplayer_jump = False\njump_velocity = 0\nGRAVITY = 1\nJUMP_STRENGTH = 15\n\n# Obstacle rectangle\nobstacle_width, obstacle_height = 40, 50\nobstacle_x = WIDTH\nobstacle_y = HEIGHT - GROUND_HEIGHT - obstacle_height\nobstacle_speed = 3\n\nscore = 0\nrunning = True\n\nwhile running:\n    for event in pygame.event.get():\n        if event.type == pygame.QUIT:\n            running = False\n\n        if event.type == pygame.KEYDOWN:\n            if event.key == pygame.K_SPACE and not player_jump:\n                player_jump = True\n                jump_velocity = -JUMP_STRENGTH\n\n    # Move player left and right\n    keys = pygame.key.get_pressed()\n    if keys&#91;pygame.K_LEFT]:\n        player_x -= player_speed\n    if keys&#91;pygame.K_RIGHT]:\n        player_x += player_speed\n\n    # Keep player inside the window\n    player_x = max(0, min(player_x, WIDTH - player_width))\n\n    # Update jump\n    if player_jump:\n        player_y += jump_velocity\n        jump_velocity += GRAVITY\n\n        if player_y >= HEIGHT - GROUND_HEIGHT - player_height:\n            player_y = HEIGHT - GROUND_HEIGHT - player_height\n            player_jump = False\n            jump_velocity = 0\n\n    # Move obstacle\n    obstacle_x -= obstacle_speed\n\n    # Reset obstacle and increase score when it leaves the screen\n    if obstacle_x &lt; -obstacle_width:\n        obstacle_x = WIDTH\n        score += 1\n\n    # Check for collision\n    player_rect = pygame.Rect(player_x, player_y, player_width, player_height)\n    obstacle_rect = pygame.Rect(\n        obstacle_x, obstacle_y, obstacle_width, obstacle_height\n    )\n\n    if player_rect.colliderect(obstacle_rect):\n        running = False\n        continue\n\n    # Draw the scene\n    screen.fill(WHITE)\n    pygame.draw.rect(\n        screen, GREEN, (0, HEIGHT - GROUND_HEIGHT, WIDTH, GROUND_HEIGHT)\n    )\n    pygame.draw.rect(screen, BLUE, player_rect)\n    pygame.draw.rect(screen, RED, obstacle_rect)\n\n    score_text = font.render(f\"Score: {score}\", True, BLACK)\n    screen.blit(score_text, (10, 10))\n\n    pygame.display.flip()\n    clock.tick(FPS)\n\n# Show game-over screen\nscreen.fill(WHITE)\ngame_over_font = pygame.font.Font(None, 72)\ngame_over_text = game_over_font.render(\"Game over\", True, RED)\nscreen.blit(\n    game_over_text,\n    game_over_text.get_rect(center=(WIDTH \/\/ 2, HEIGHT \/\/ 2))\n)\npygame.display.flip()\n\npygame.time.delay(2000)\npygame.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and down here you can see how it looks like <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"423\" src=\"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-3.png\" alt=\"\" class=\"wp-image-174\" srcset=\"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-3.png 791w, https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-3-300x160.png 300w, https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-3-767x410.png 767w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I did the code from youtube <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"542\" src=\"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-4-1024x542.png\" alt=\"\" class=\"wp-image-175\" srcset=\"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-4-1024x542.png 1024w, https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-4-300x159.png 300w, https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-4-767x406.png 767w, https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-content\/uploads\/2026\/10\/image-4.png 1327w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">hope you like it <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>so i made a game named so i made a game named \u00a0Subway Surfer here i will post all the [&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-173","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/posts\/173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/comments?post=173"}],"version-history":[{"count":1,"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/posts\/173\/revisions"}],"predecessor-version":[{"id":176,"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/posts\/173\/revisions\/176"}],"wp:attachment":[{"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/media?parent=173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/categories?post=173"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theroyalscode.com\/students\/a_mehraban\/wp-json\/wp\/v2\/tags?post=173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}