Alyf E

23 Januari 2026 19:28

Iklan

Alyf E

23 Januari 2026 19:28

Pertanyaan

Coding program making game 1. Racer game 2. Football game 3. War game

Coding program making game 

1. Racer game 

2. Football game

3. War game

Ikuti Tryout SNBT & Menangkan E-Wallet 100rb

Habis dalam

00

:

22

:

38

:

56

Klaim

12

2


Iklan

ThatAxolotlGD T

24 Januari 2026 03:22

<p>multi arcade game Programming code</p><p>racer game</p><p>football game</p><p>FPS game (first person shooter)</p><p>&nbsp;</p><p>import pygame, sys, random</p><p>pygame.init()<br>WIDTH, HEIGHT = 800, 600<br>screen = pygame.display.set_mode((WIDTH, HEIGHT))<br>clock = pygame.time.Clock()<br>font = pygame.font.SysFont("Arial", 36)</p><p># ---------------- MENU ----------------<br>def menu():<br>&nbsp; &nbsp;while True:<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.fill((30,30,30))<br>&nbsp; &nbsp; &nbsp; &nbsp;title = font.render("🎮 Arcade Menu", True, (255,255,255))<br>&nbsp; &nbsp; &nbsp; &nbsp;racer = font.render("1. Racer Game 🚗", True, (200,200,0))<br>&nbsp; &nbsp; &nbsp; &nbsp;football = font.render("2. Football Game 🏈", True, (0,200,0))<br>&nbsp; &nbsp; &nbsp; &nbsp;war = font.render("3. War Game ⚔️", True, (200,0,0))<br>&nbsp; &nbsp; &nbsp; &nbsp;quit_text = font.render("ESC to Quit", True, (255,255,255))</p><p>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(title,(WIDTH//2-150,100))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(racer,(WIDTH//2-150,200))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(football,(WIDTH//2-150,300))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(war,(WIDTH//2-150,400))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(quit_text,(WIDTH//2-150,500))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.display.flip()</p><p>&nbsp; &nbsp; &nbsp; &nbsp;for event in pygame.event.get():<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.QUIT: pygame.quit(); sys.exit()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.KEYDOWN:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.key == pygame.K_1: racer_game()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.key == pygame.K_2: football_game()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.key == pygame.K_3: war_game()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.key == pygame.K_ESCAPE: pygame.quit(); sys.exit()</p><p># ---------------- RACER GAME ----------------<br>def racer_game():<br>&nbsp; &nbsp;car = pygame.Rect(WIDTH//2, HEIGHT-120, 50,100)<br>&nbsp; &nbsp;obstacles = []<br>&nbsp; &nbsp;score = 0<br>&nbsp; &nbsp;speed = 6</p><p>&nbsp; &nbsp;while True:<br>&nbsp; &nbsp; &nbsp; &nbsp;for event in pygame.event.get():<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.QUIT: pygame.quit(); sys.exit()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return</p><p>&nbsp; &nbsp; &nbsp; &nbsp;keys = pygame.key.get_pressed()<br>&nbsp; &nbsp; &nbsp; &nbsp;if keys[pygame.K_LEFT]: car.x -= 7<br>&nbsp; &nbsp; &nbsp; &nbsp;if keys[pygame.K_RIGHT]: car.x += 7</p><p>&nbsp; &nbsp; &nbsp; &nbsp;# Spawn obstacles<br>&nbsp; &nbsp; &nbsp; &nbsp;if random.randint(1,25) == 1:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;obstacles.append(pygame.Rect(random.randint(0,WIDTH-50), -100, 50,100))</p><p>&nbsp; &nbsp; &nbsp; &nbsp;# Move obstacles<br>&nbsp; &nbsp; &nbsp; &nbsp;for obs in obstacles[:]:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;obs.y += speed<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if obs.colliderect(car):<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;game_over("Racer", score); return<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if obs.y &gt; HEIGHT: obstacles.remove(obs); score += 1</p><p>&nbsp; &nbsp; &nbsp; &nbsp;screen.fill((50,50,50))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.draw.rect(screen,(255,0,0),car)<br>&nbsp; &nbsp; &nbsp; &nbsp;for obs in obstacles: pygame.draw.rect(screen,(0,0,255),obs)<br>&nbsp; &nbsp; &nbsp; &nbsp;score_text = font.render(f"Score: {score}", True, (255,255,255))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(score_text,(10,10))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.display.flip()<br>&nbsp; &nbsp; &nbsp; &nbsp;clock.tick(60)</p><p># ---------------- FOOTBALL GAME ----------------<br>def football_game():<br>&nbsp; &nbsp;ball = pygame.Rect(WIDTH//2, HEIGHT//2, 20,20)<br>&nbsp; &nbsp;ball_speed = [5,4]<br>&nbsp; &nbsp;player = pygame.Rect(WIDTH//2-40, HEIGHT-40, 80,20)<br>&nbsp; &nbsp;score = 0</p><p>&nbsp; &nbsp;while True:<br>&nbsp; &nbsp; &nbsp; &nbsp;for event in pygame.event.get():<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.QUIT: pygame.quit(); sys.exit()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return</p><p>&nbsp; &nbsp; &nbsp; &nbsp;keys = pygame.key.get_pressed()<br>&nbsp; &nbsp; &nbsp; &nbsp;if keys[pygame.K_LEFT]: player.x -= 7<br>&nbsp; &nbsp; &nbsp; &nbsp;if keys[pygame.K_RIGHT]: player.x += 7</p><p>&nbsp; &nbsp; &nbsp; &nbsp;# Ball movement<br>&nbsp; &nbsp; &nbsp; &nbsp;ball.x += ball_speed[0]<br>&nbsp; &nbsp; &nbsp; &nbsp;ball.y += ball_speed[1]</p><p>&nbsp; &nbsp; &nbsp; &nbsp;if ball.left &lt;= 0 or ball.right &gt;= WIDTH: ball_speed[0] = -ball_speed[0]<br>&nbsp; &nbsp; &nbsp; &nbsp;if ball.top &lt;= 0: ball_speed[1] = -ball_speed[1]<br>&nbsp; &nbsp; &nbsp; &nbsp;if ball.bottom &gt;= HEIGHT: game_over("Football", score); return</p><p>&nbsp; &nbsp; &nbsp; &nbsp;if ball.colliderect(player):<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ball_speed[1] = -ball_speed[1]<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;score += 1</p><p>&nbsp; &nbsp; &nbsp; &nbsp;screen.fill((0,100,0))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.draw.ellipse(screen,(255,255,255),ball)<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.draw.rect(screen,(0,0,255),player)<br>&nbsp; &nbsp; &nbsp; &nbsp;score_text = font.render(f"Score: {score}", True, (255,255,255))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(score_text,(10,10))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.display.flip()<br>&nbsp; &nbsp; &nbsp; &nbsp;clock.tick(60)</p><p># ---------------- WAR GAME ----------------<br>def war_game():<br>&nbsp; &nbsp;player = pygame.Rect(WIDTH//2, HEIGHT-60, 40,40)<br>&nbsp; &nbsp;bullets = []<br>&nbsp; &nbsp;enemies = []<br>&nbsp; &nbsp;score = 0</p><p>&nbsp; &nbsp;while True:<br>&nbsp; &nbsp; &nbsp; &nbsp;for event in pygame.event.get():<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.QUIT: pygame.quit(); sys.exit()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.KEYDOWN:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.key == pygame.K_ESCAPE: return<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.key == pygame.K_SPACE:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bullets.append(pygame.Rect(player.centerx, player.top, 5,10))</p><p>&nbsp; &nbsp; &nbsp; &nbsp;keys = pygame.key.get_pressed()<br>&nbsp; &nbsp; &nbsp; &nbsp;if keys[pygame.K_LEFT]: player.x -= 7<br>&nbsp; &nbsp; &nbsp; &nbsp;if keys[pygame.K_RIGHT]: player.x += 7</p><p>&nbsp; &nbsp; &nbsp; &nbsp;# Spawn enemies<br>&nbsp; &nbsp; &nbsp; &nbsp;if random.randint(1,40) == 1:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;enemies.append(pygame.Rect(random.randint(0,WIDTH-40), -40, 40,40))</p><p>&nbsp; &nbsp; &nbsp; &nbsp;# Move bullets<br>&nbsp; &nbsp; &nbsp; &nbsp;for b in bullets[:]:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;b.y -= 10<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if b.y &lt; 0: bullets.remove(b)</p><p>&nbsp; &nbsp; &nbsp; &nbsp;# Move enemies<br>&nbsp; &nbsp; &nbsp; &nbsp;for e in enemies[:]:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;e.y += 5<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if e.colliderect(player): game_over("War", score); return<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for b in bullets[:]:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if e.colliderect(b):<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;enemies.remove(e)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bullets.remove(b)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;score += 1<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if e.y &gt; HEIGHT: enemies.remove(e)</p><p>&nbsp; &nbsp; &nbsp; &nbsp;screen.fill((20,20,20))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.draw.rect(screen,(0,255,0),player)<br>&nbsp; &nbsp; &nbsp; &nbsp;for b in bullets: pygame.draw.rect(screen,(255,255,0),b)<br>&nbsp; &nbsp; &nbsp; &nbsp;for e in enemies: pygame.draw.rect(screen,(255,0,0),e)<br>&nbsp; &nbsp; &nbsp; &nbsp;score_text = font.render(f"Score: {score}", True, (255,255,255))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(score_text,(10,10))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.display.flip()<br>&nbsp; &nbsp; &nbsp; &nbsp;clock.tick(60)</p><p># ---------------- GAME OVER ----------------<br>def game_over(game_name, score):<br>&nbsp; &nbsp;while True:<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.fill((0,0,0))<br>&nbsp; &nbsp; &nbsp; &nbsp;over_text = font.render(f"{game_name} Game Over!", True, (255,0,0))<br>&nbsp; &nbsp; &nbsp; &nbsp;score_text = font.render(f"Final Score: {score}", True, (255,255,255))<br>&nbsp; &nbsp; &nbsp; &nbsp;retry_text = font.render("Press ESC for Menu", True, (200,200,200))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(over_text,(WIDTH//2-150,200))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(score_text,(WIDTH//2-150,300))<br>&nbsp; &nbsp; &nbsp; &nbsp;screen.blit(retry_text,(WIDTH//2-150,400))<br>&nbsp; &nbsp; &nbsp; &nbsp;pygame.display.flip()</p><p>&nbsp; &nbsp; &nbsp; &nbsp;for event in pygame.event.get():<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.QUIT: pygame.quit(); sys.exit()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return</p><p># ---------------- RUN ----------------<br>menu()<br>&nbsp;</p><h2>Features</h2><p><strong>Main Menu</strong>: Choose between Racer, Football, or War game.</p><p><strong>Escape key</strong>: Returns to menu from any game.</p><p><strong>Game Over screen</strong>: Shows final score and lets you return to menu.</p><p><strong>Replayable loop</strong>: You can play endlessly switching between games.</p><p>&nbsp;Save this as arcade.py, install Pygame (pip install pygame), and run with python arcade.py.</p><p>&nbsp;</p>

multi arcade game Programming code

racer game

football game

FPS game (first person shooter)

 

import pygame, sys, random

pygame.init()
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
font = pygame.font.SysFont("Arial", 36)

# ---------------- MENU ----------------
def menu():
   while True:
       screen.fill((30,30,30))
       title = font.render("🎮 Arcade Menu", True, (255,255,255))
       racer = font.render("1. Racer Game 🚗", True, (200,200,0))
       football = font.render("2. Football Game 🏈", True, (0,200,0))
       war = font.render("3. War Game ⚔️", True, (200,0,0))
       quit_text = font.render("ESC to Quit", True, (255,255,255))

       screen.blit(title,(WIDTH//2-150,100))
       screen.blit(racer,(WIDTH//2-150,200))
       screen.blit(football,(WIDTH//2-150,300))
       screen.blit(war,(WIDTH//2-150,400))
       screen.blit(quit_text,(WIDTH//2-150,500))
       pygame.display.flip()

       for event in pygame.event.get():
           if event.type == pygame.QUIT: pygame.quit(); sys.exit()
           if event.type == pygame.KEYDOWN:
               if event.key == pygame.K_1: racer_game()
               if event.key == pygame.K_2: football_game()
               if event.key == pygame.K_3: war_game()
               if event.key == pygame.K_ESCAPE: pygame.quit(); sys.exit()

# ---------------- RACER GAME ----------------
def racer_game():
   car = pygame.Rect(WIDTH//2, HEIGHT-120, 50,100)
   obstacles = []
   score = 0
   speed = 6

   while True:
       for event in pygame.event.get():
           if event.type == pygame.QUIT: pygame.quit(); sys.exit()
           if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return

       keys = pygame.key.get_pressed()
       if keys[pygame.K_LEFT]: car.x -= 7
       if keys[pygame.K_RIGHT]: car.x += 7

       # Spawn obstacles
       if random.randint(1,25) == 1:
           obstacles.append(pygame.Rect(random.randint(0,WIDTH-50), -100, 50,100))

       # Move obstacles
       for obs in obstacles[:]:
           obs.y += speed
           if obs.colliderect(car):
               game_over("Racer", score); return
           if obs.y > HEIGHT: obstacles.remove(obs); score += 1

       screen.fill((50,50,50))
       pygame.draw.rect(screen,(255,0,0),car)
       for obs in obstacles: pygame.draw.rect(screen,(0,0,255),obs)
       score_text = font.render(f"Score: {score}", True, (255,255,255))
       screen.blit(score_text,(10,10))
       pygame.display.flip()
       clock.tick(60)

# ---------------- FOOTBALL GAME ----------------
def football_game():
   ball = pygame.Rect(WIDTH//2, HEIGHT//2, 20,20)
   ball_speed = [5,4]
   player = pygame.Rect(WIDTH//2-40, HEIGHT-40, 80,20)
   score = 0

   while True:
       for event in pygame.event.get():
           if event.type == pygame.QUIT: pygame.quit(); sys.exit()
           if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return

       keys = pygame.key.get_pressed()
       if keys[pygame.K_LEFT]: player.x -= 7
       if keys[pygame.K_RIGHT]: player.x += 7

       # Ball movement
       ball.x += ball_speed[0]
       ball.y += ball_speed[1]

       if ball.left <= 0 or ball.right >= WIDTH: ball_speed[0] = -ball_speed[0]
       if ball.top <= 0: ball_speed[1] = -ball_speed[1]
       if ball.bottom >= HEIGHT: game_over("Football", score); return

       if ball.colliderect(player):
           ball_speed[1] = -ball_speed[1]
           score += 1

       screen.fill((0,100,0))
       pygame.draw.ellipse(screen,(255,255,255),ball)
       pygame.draw.rect(screen,(0,0,255),player)
       score_text = font.render(f"Score: {score}", True, (255,255,255))
       screen.blit(score_text,(10,10))
       pygame.display.flip()
       clock.tick(60)

# ---------------- WAR GAME ----------------
def war_game():
   player = pygame.Rect(WIDTH//2, HEIGHT-60, 40,40)
   bullets = []
   enemies = []
   score = 0

   while True:
       for event in pygame.event.get():
           if event.type == pygame.QUIT: pygame.quit(); sys.exit()
           if event.type == pygame.KEYDOWN:
               if event.key == pygame.K_ESCAPE: return
               if event.key == pygame.K_SPACE:
                   bullets.append(pygame.Rect(player.centerx, player.top, 5,10))

       keys = pygame.key.get_pressed()
       if keys[pygame.K_LEFT]: player.x -= 7
       if keys[pygame.K_RIGHT]: player.x += 7

       # Spawn enemies
       if random.randint(1,40) == 1:
           enemies.append(pygame.Rect(random.randint(0,WIDTH-40), -40, 40,40))

       # Move bullets
       for b in bullets[:]:
           b.y -= 10
           if b.y < 0: bullets.remove(b)

       # Move enemies
       for e in enemies[:]:
           e.y += 5
           if e.colliderect(player): game_over("War", score); return
           for b in bullets[:]:
               if e.colliderect(b):
                   enemies.remove(e)
                   bullets.remove(b)
                   score += 1
                   break
           if e.y > HEIGHT: enemies.remove(e)

       screen.fill((20,20,20))
       pygame.draw.rect(screen,(0,255,0),player)
       for b in bullets: pygame.draw.rect(screen,(255,255,0),b)
       for e in enemies: pygame.draw.rect(screen,(255,0,0),e)
       score_text = font.render(f"Score: {score}", True, (255,255,255))
       screen.blit(score_text,(10,10))
       pygame.display.flip()
       clock.tick(60)

# ---------------- GAME OVER ----------------
def game_over(game_name, score):
   while True:
       screen.fill((0,0,0))
       over_text = font.render(f"{game_name} Game Over!", True, (255,0,0))
       score_text = font.render(f"Final Score: {score}", True, (255,255,255))
       retry_text = font.render("Press ESC for Menu", True, (200,200,200))
       screen.blit(over_text,(WIDTH//2-150,200))
       screen.blit(score_text,(WIDTH//2-150,300))
       screen.blit(retry_text,(WIDTH//2-150,400))
       pygame.display.flip()

       for event in pygame.event.get():
           if event.type == pygame.QUIT: pygame.quit(); sys.exit()
           if event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: return

# ---------------- RUN ----------------
menu()
 

Features

Main Menu: Choose between Racer, Football, or War game.

Escape key: Returns to menu from any game.

Game Over screen: Shows final score and lets you return to menu.

Replayable loop: You can play endlessly switching between games.

 Save this as arcade.py, install Pygame (pip install pygame), and run with python arcade.py.

 


ThatAxolotlGD T

24 Januari 2026 03:23

**works with phyton**

— Tampilkan 1 balasan lainnya

Iklan

Humaira N

31 Januari 2026 11:58

<p>Do you speak Indonesia🇮🇩</p>

Do you speak Indonesia🇮🇩


ThatAxolotlGD T

Dijawab 6 hari yang lalu

Idk why?

Mau jawaban yang terverifikasi?

Tanya ke AiRIS

Yuk, cobain chat dan belajar bareng AiRIS, teman pintarmu!

Chat AiRIS

Roboguru Plus

Dapatkan pembahasan soal ga pake lama, langsung dari Tutor!

Chat Tutor

Perdalam pemahamanmu bersama Master Teacher
di sesi Live Teaching, GRATIS!

Pertanyaan serupa

Perhatikan kelompok masyarakat berikut ini! 1. Petani 2. Pedagang 3. Pegawai 4. Pengusaha 5. Buruh 6. Spekulan Kelompok masyarakat yang dirugikan dengan adanya inflasi adalah ....* 1, 2, dan 4 1, 3, dan 5 1, 4, dan 6 2, 3, dan 5 2, 4, dan 6

7

1.0

Jawaban terverifikasi