Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =================================
- Code Generated by GPT-4:
- =================================
- import pygame
- import random
- import time
- pygame.init()
- width, height = 800, 600
- screen = pygame.display.set_mode((width, height))
- clock = pygame.time.Clock()
- # Initial position of the line
- line_x = width // 2
- def move_line():
- global line_x
- move_rate = random.choice([-5, 5]) # Line moves left or right randomly
- while 0 < line_x < width:
- line_x += move_rate
- yield
- if line_x <= 0 or line_x >= width:
- break
- # Main game loop
- running = True
- line_movement = move_line()
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- elif event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a and move_rate > 0: # Player A stops the line moving left
- line_movement = move_line()
- elif event.key == pygame.K_l and move_rate < 0: # Player L stops the line moving right
- line_movement = move_line()
- next(line_movement, None) # Move the line
- screen.fill((0, 0, 0))
- pygame.draw.line(screen, (255, 255, 255), (line_x, 0), (line_x, height))
- pygame.display.flip()
- clock.tick(60)
- pygame.quit()
- =================================
- Code Generated by LlaMA-3:
- =================================
- import pygame
- import random
- import time
- # Initialize Pygame
- pygame.init()
- # Set up the game window dimensions
- WINDOW_WIDTH = 800
- WINDOW_HEIGHT = 600
- screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
- # Set up the title of the window
- pygame.display.set_caption("Territory Tussle")
- # Define some colors
- WHITE = (255, 255, 255)
- BLACK = (0, 0, 0)
- RED = (255, 0, 0)
- GREEN = (0, 255, 0)
- # Set up the game variables
- player_A_territory = 50
- player_L_territory = 50
- line_x = WINDOW_WIDTH / 2
- line_speed = 2
- player_A_score = 0
- player_L_score = 0
- moving_right = True
- game_over = False
- # Set up the game clock
- clock = pygame.time.Clock()
- # Game loop
- while True:
- # Event handling
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- elif event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a:
- if not moving_right:
- moving_right = True
- line_speed = 2
- elif event.key == pygame.K_l:
- if moving_right:
- moving_right = False
- line_speed = 2
- elif event.type == pygame.KEYUP:
- line_speed = 2
- # Move the line
- if moving_right:
- line_x += line_speed
- else:
- line_x -= line_speed
- # Check for boundary collisions
- if line_x <= 0:
- line_x = 0
- elif line_x >= WINDOW_WIDTH:
- line_x = WINDOW_WIDTH
- # Update the game state
- if player_A_territory <= 0 or player_L_territory <= 0:
- game_over = True
- elif player_A_territory >= 100 or player_L_territory >= 100:
- game_over = True
- # Draw everything
- screen.fill(WHITE)
- pygame.draw.line(screen, BLACK, (line_x, 0), (line_x, WINDOW_HEIGHT), 2)
- pygame.draw.rect(screen, RED, (0, 0, line_x, WINDOW_HEIGHT))
- pygame.draw.rect(screen, GREEN, (line_x, 0, WINDOW_WIDTH - line_x, WINDOW_HEIGHT))
- # Game over banner
- if game_over:
- banner_font = pygame.font.SysFont("Arial", 50)
- banner_text = banner_font.render("Game Over! Press R to restart.", True, BLACK)
- screen.blit(banner_text, (100, 100))
- # Restart button
- restart_font = pygame.font.SysFont("Arial", 30)
- restart_text = restart_font.render("R", True, BLACK)
- screen.blit(restart_text, (100, 200))
- # Dominance percentage
- if player_A_score + player_L_score > 0:
- dominance_font = pygame.font.SysFont("Arial", 20)
- if player_A_territory >= 100:
- dominance_text = dominance_font.render(f"Player A dominance: 100%", True, BLACK)
- else:
- dominance_text = dominance_font.render(f"Player A dominance: {player_A_score / (player_A_score + player_L_score) * 100:.2f}%", True, BLACK)
- screen.blit(dominance_text, (100, 300))
- if player_L_territory >= 100:
- dominance_text = dominance_font.render(f"Player L dominance: 100%", True, BLACK)
- else:
- dominance_text = dominance_font.render(f"Player L dominance: {player_L_score / (player_A_score + player_L_score) * 100:.2f}%", True, BLACK)
- screen.blit(dominance_text, (100, 350))
- # Update the display
- pygame.display.flip()
- # Cap the frame rate
- clock.tick(60)
- # Check for restart
- keys = pygame.key.get_pressed()
- if keys[pygame.K_r] and game_over:
- player_A_territory = 50
- player_L_territory = 50
- line_x = WINDOW_WIDTH / 2
- game_over = False
- =================================
- Code generated by Claude 3 Sonnet:
- =================================
- import pygame
- import random
- import time
- # Initialize Pygame
- pygame.init()
- # Set up the game window
- WINDOW_WIDTH = 800
- WINDOW_HEIGHT = 600
- window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
- pygame.display.set_caption("Line Game")
- # Define colors
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- RED = (255, 0, 0)
- BLUE = (0, 0, 255)
- # Game variables
- player1_territory = WINDOW_WIDTH // 2
- player2_territory = WINDOW_WIDTH // 2
- line_position = WINDOW_WIDTH // 2
- line_moving = False
- line_speed = 5
- line_direction = 0 # 0 = left, 1 = right
- move_interval = 3 # seconds
- # Game loop
- running = True
- clock = pygame.time.Clock()
- last_move_time = time.time()
- while running:
- clock.tick(60) # Limit frame rate
- # Handle events
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- # Player input
- keys = pygame.key.get_pressed()
- if keys[pygame.K_a] and line_moving and line_direction == 1:
- line_moving = False
- if keys[pygame.K_l] and line_moving and line_direction == 0:
- line_moving = False
- # Move the line
- if not line_moving:
- current_time = time.time()
- if current_time - last_move_time > move_interval:
- line_moving = True
- line_direction = random.randint(0, 1)
- last_move_time = current_time
- if line_moving:
- if line_direction == 0: # Move left
- line_position -= line_speed
- else: # Move right
- line_position += line_speed
- # Update player territories
- player1_territory = line_position
- player2_territory = WINDOW_WIDTH - line_position
- # Check for game over
- if player1_territory <= 0:
- print("Player 2 wins!")
- running = False
- elif player2_territory <= 0:
- print("Player 1 wins!")
- running = False
- # Clear the window
- window.fill(BLACK)
- # Draw the line
- pygame.draw.line(window, WHITE, (line_position, 0), (line_position, WINDOW_HEIGHT), 2)
- # Draw player territories
- pygame.draw.rect(window, RED, (0, 0, player1_territory, WINDOW_HEIGHT))
- pygame.draw.rect(window, BLUE, (player1_territory, 0, player2_territory, WINDOW_HEIGHT))
- # Update the display
- pygame.display.flip()
- # Quit Pygame
- pygame.quit()
Advertisement
Comments
-
- Prompt:
- I want to create a game.
- To players play against each other in the same computer. One is in control of the letter L and the other controls the letter A.
- We have a field divided by two with a line. Each player controls 50% of the field. The player who controls A controls the left half and the one who controls L controls the right half
- At a random momemnt, the line will move towards either the left or the right.
- The player who is losing ground must pres the button as fast as possible to prevent the line from moving anymore.
- When that's done, the line will stay in place and players will have to wait until the line starts to move at a random moment to a random location.
- The player who ends up controling 0% of the screen loses and the game ends
-
- Code created by Reka Core:
- import pygame
- import random
- import time
- # Initialize Pygame
- pygame.init()
- # Game window dimensions
- WINDOW_WIDTH = 800
- WINDOW_HEIGHT = 400
- # Create the game window
- screen = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
- # Set the window title
- pygame.display.set_caption("Letter Game")
- # Line movement speed
- LINE_SPEED = 5
- # Player colors
- PLAYER_A_COLOR = (255, 0, 0)
- PLAYER_L_COLOR = (0, 0, 255)
- # Game field dimensions
- FIELD_WIDTH = WINDOW_WIDTH
- FIELD_HEIGHT = WINDOW_HEIGHT // 2
- # Player-controlled areas
- player_a_area = FIELD_WIDTH // 2
- player_l_area = FIELD_WIDTH // 2
- # Line position
- line_x = WINDOW_WIDTH // 2
- line_y = FIELD_HEIGHT
- # Line direction
- line_direction = random.choice([-1, 1])
- # Game loop
- running = True
- while running:
- # Handle events
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- elif event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a and line_x <= FIELD_WIDTH * 3 // 4:
- line_x = FIELD_WIDTH * 3 // 4
- line_direction = 1
- time.sleep(random.uniform(0, 5))
- elif event.key == pygame.K_l and line_x >= FIELD_WIDTH // 4:
- line_x = FIELD_WIDTH // 4
- line_direction = -1
- time.sleep(random.uniform(0, 5))
- # Move the line in a specific direction
- line_x += line_direction * LINE_SPEED
- # Check if a player is losing ground
- if line_x <= FIELD_WIDTH // 4:
- player_l_area -= LINE_SPEED
- line_x = FIELD_WIDTH // 2 - player_a_area
- elif line_x >= FIELD_WIDTH * 3 // 4:
- player_a_area -= LINE_SPEED
- line_x = FIELD_WIDTH // 2 + player_l_area
- # Update player-controlled areas
- player_a_area = FIELD_WIDTH // 2 - line_x
- player_l_area = line_x - FIELD_WIDTH // 2
- # Draw the game field
- screen.fill((255, 255, 255))
- pygame.draw.line(screen, (0, 0, 0), (line_x, line_y), (line_x, WINDOW_HEIGHT), 2)
- pygame.draw.rect(screen, PLAYER_A_COLOR, (0, 0, player_a_area, FIELD_HEIGHT))
- pygame.draw.rect(screen, PLAYER_L_COLOR, (player_a_area, 0, player_l_area, FIELD_HEIGHT))
- # Update the display
- pygame.display.flip()
- # Wait for the next line movement
- time.sleep(0.1)
- # Game over screen
- pygame.display.set_caption("Game Over")
- screen.fill((255, 255, 255))
- if player_a_area == 0:
- winner = "Player L"
- elif player_l_area == 0:
- winner = "Player A"
- text = pygame.font.Font(None, 36).render(f"Winner: {winner}", True, (0, 0, 0))
- text_rect = text.get_rect(center=(WINDOW_WIDTH // 2, WINDOW_HEIGHT // 2))
- screen.blit(text, text_rect)
- pygame.display.flip()
- time.sleep(3)
- # Quit Pygame
- pygame.quit()
-
- Code created by Claude Sonnet 3.5:
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Two-Player Line Game</title>
- <style>
- body {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100vh;
- margin: 0;
- font-family: Arial, sans-serif;
- }
- #gameContainer {
- width: 600px;
- height: 300px;
- position: relative;
- overflow: hidden;
- }
- #player1, #player2 {
- position: absolute;
- top: 0;
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 48px;
- color: white;
- }
- #player1 {
- left: 0;
- background-color: red;
- }
- #player2 {
- right: 0;
- background-color: blue;
- }
- #divider {
- position: absolute;
- top: 0;
- width: 4px;
- height: 100%;
- background-color: black;
- }
- #instructions {
- position: absolute;
- bottom: 10px;
- text-align: center;
- width: 100%;
- }
- </style>
- </head>
- <body>
- <div id="gameContainer">
- <div id="player1"></div>
- <div id="player2"></div>
- <div id="divider"></div>
- <div id="instructions">Player 1: Press 'A' | Player 2: Press 'L'</div>
- </div>
- <script>
- const gameContainer = document.getElementById('gameContainer');
- const player1 = document.getElementById('player1');
- const player2 = document.getElementById('player2');
- const divider = document.getElementById('divider');
- let gameWidth = gameContainer.offsetWidth;
- let dividerPosition = gameWidth / 2;
- let isMoving = false;
- let moveDirection = 0;
- let moveSpeed = 1;
- function updateGame() {
- player1.style.width = `${dividerPosition}px`;
- player2.style.width = `${gameWidth - dividerPosition}px`;
- divider.style.left = `${dividerPosition}px`;
- player1.textContent = dividerPosition > 0 ? 'A' : '';
- player2.textContent = dividerPosition < gameWidth ? 'L' : '';
- if (dividerPosition <= 0 || dividerPosition >= gameWidth) {
- endGame();
- }
- }
- function startMoving() {
- if (!isMoving) {
- isMoving = true;
- moveDirection = Math.random() > 0.5 ? 1 : -1;
- moveDivider();
- }
- }
- function moveDivider() {
- if (isMoving) {
- dividerPosition += moveDirection * moveSpeed;
- updateGame();
- requestAnimationFrame(moveDivider);
- }
- }
- function stopMoving() {
- if (isMoving) {
- isMoving = false;
- setTimeout(startMoving, 1000);
- }
- }
- function endGame() {
- isMoving = false;
- alert(dividerPosition <= 0 ? "Player 2 (L) wins!" : "Player 1 (A) wins!");
- }
- document.addEventListener('keydown', (event) => {
- if (event.key.toLowerCase() === 'a' && moveDirection > 0) {
- stopMoving();
- } else if (event.key.toLowerCase() === 'l' && moveDirection < 0) {
- stopMoving();
- }
- });
- updateGame();
- setTimeout(startMoving, 1000);
- </script>
- </body>
- </html>
-
- Claude 3.5 Sonnet
- import pygame
- import random
- import time
- # Initialize Pygame
- pygame.init()
- # Set up the display
- WIDTH, HEIGHT = 800, 600
- screen = pygame.display.set_mode((WIDTH, HEIGHT))
- pygame.display.set_caption("Two-Player Line Game")
- # Colors
- BLACK = (0, 0, 0)
- WHITE = (255, 255, 255)
- RED = (255, 0, 0)
- BLUE = (0, 0, 255)
- # Game variables
- line_pos = WIDTH // 2
- move_direction = 0
- move_speed = 100 # pixels per second
- last_move_time = 0
- wait_time = random.uniform(1, 5) # Random wait time between 1 and 5 seconds
- # Font
- font = pygame.font.Font(None, 36)
- def draw_game():
- screen.fill(BLACK)
- pygame.draw.rect(screen, BLUE, (0, 0, line_pos, HEIGHT))
- pygame.draw.rect(screen, RED, (line_pos, 0, WIDTH - line_pos, HEIGHT))
- pygame.draw.line(screen, WHITE, (line_pos, 0), (line_pos, HEIGHT), 2)
- # Draw player labels
- a_text = font.render("A", True, WHITE)
- l_text = font.render("L", True, WHITE)
- screen.blit(a_text, (20, HEIGHT // 2))
- screen.blit(l_text, (WIDTH - 40, HEIGHT // 2))
- # Draw percentage
- a_percent = font.render(f"{int(line_pos / WIDTH * 100)}%", True, WHITE)
- l_percent = font.render(f"{int((WIDTH - line_pos) / WIDTH * 100)}%", True, WHITE)
- screen.blit(a_percent, (line_pos // 2 - 20, 20))
- screen.blit(l_percent, (line_pos + (WIDTH - line_pos) // 2 - 20, 20))
- pygame.display.flip()
- def game_over(winner):
- screen.fill(BLACK)
- text = font.render(f"Player {winner} wins!", True, WHITE)
- screen.blit(text, (WIDTH // 2 - 100, HEIGHT // 2))
- pygame.display.flip()
- pygame.time.wait(3000)
- running = True
- clock = pygame.time.Clock()
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a and move_direction < 0:
- move_direction = 0
- if event.key == pygame.K_l and move_direction > 0:
- move_direction = 0
- current_time = time.time()
- if move_direction == 0 and current_time - last_move_time > wait_time:
- move_direction = random.choice([-1, 1])
- last_move_time = current_time
- wait_time = random.uniform(1, 5)
- if move_direction != 0:
- line_pos += move_direction * move_speed * clock.get_time() / 1000
- if line_pos <= 0:
- game_over("L")
- running = False
- elif line_pos >= WIDTH:
- game_over("A")
- running = False
- line_pos = max(0, min(WIDTH, line_pos))
- draw_game()
- clock.tick(60)
- pygame.quit()
-
- Grok 2 (sus-column-r)
- import pygame
- import random
- import time
- # Initialize Pygame
- pygame.init()
- # Screen setup
- WIDTH, HEIGHT = 800, 400
- screen = pygame.display.set_mode((WIDTH, HEIGHT))
- pygame.display.set_caption('Line of Letters')
- # Colors
- WHITE = (255, 255, 255)
- BLACK = (0, 0, 0)
- RED = (255, 0, 0)
- BLUE = (0, 0, 255)
- # Game variables
- line_position = WIDTH // 2
- player_a_score = player_l_score = 50
- move_delay = 2 # Seconds before the line can move again
- last_move_time = time.time()
- move_direction = 0 # -1 for left, 1 for right, 0 for stationary
- # Function to reset the game state
- def reset_game():
- global line_position, player_a_score, player_l_score, last_move_time
- line_position = WIDTH // 2
- player_a_score = player_l_score = 50
- last_move_time = time.time()
- # Game loop
- clock = pygame.time.Clock()
- running = True
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- # Random movement of the line
- current_time = time.time()
- if current_time - last_move_time > move_delay and random.random() < 0.01: # 1% chance each frame after the delay
- move_direction = random.choice([-1, 1])
- last_move_time = current_time
- elif current_time - last_move_time > move_delay:
- move_direction = 0 # Stop moving if delay has passed
- keys = pygame.key.get_pressed()
- # Player A (left side, pressing 'A')
- if keys[pygame.K_a]:
- line_position -= 1 if move_direction != 1 else 2 # Counteract the line's random move
- # Player L (right side, pressing 'L')
- if keys[pygame.K_l]:
- line_position += 1 if move_direction != -1 else 2
- # Keep line within bounds
- line_position = max(0, min(line_position, WIDTH))
- # Update scores
- player_a_score = line_position * 100 // WIDTH
- player_l_score = 100 - player_a_score
- # Drawing
- screen.fill(WHITE)
- pygame.draw.line(screen, BLACK, (line_position, 0), (line_position, HEIGHT), 2)
- # Draw territories
- pygame.draw.rect(screen, RED, (0, 0, line_position, HEIGHT))
- pygame.draw.rect(screen, BLUE, (line_position, 0, WIDTH - line_position, HEIGHT))
- # Display scores or player indicators
- font = pygame.font.Font(None, 36)
- text_a = font.render(f'A: {player_a_score}%', True, BLACK)
- text_l = font.render(f'L: {player_l_score}%', True, BLACK)
- screen.blit(text_a, (10, 10))
- screen.blit(text_l, (WIDTH - 100, 10))
- # Check for win condition
- if player_a_score <= 0 or player_l_score <= 0:
- winner = 'L' if player_a_score <= 0 else 'A'
- win_text = font.render(f'Player {winner} wins!', True, BLACK)
- screen.blit(win_text, (WIDTH//2 - 100, HEIGHT//2))
- pygame.display.flip()
- pygame.time.wait(3000)
- reset_game()
- pygame.display.flip()
- clock.tick(60) # 60 FPS
- pygame.quit()
-
- Grok 2 Mini:
- import pygame
- import random
- # Initialize Pygame
- pygame.init()
- # Constants
- SCREEN_WIDTH = 800
- SCREEN_HEIGHT = 600
- LINE_WIDTH = 10
- FPS = 60
- # Colors
- WHITE = (255, 255, 255)
- BLACK = (0, 0, 0)
- RED = (255, 0, 0)
- GREEN = (0, 255, 0)
- # Setup
- screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
- pygame.display.set_caption("L vs A Game")
- clock = pygame.time.Clock()
- # Game variables
- line_position = SCREEN_WIDTH // 2
- line_speed = 10
- line_direction = 1 # 1 for right, -1 for left
- game_over = False
- button_pressed = False
- # Player controls
- A_KEY = pygame.K_a
- L_KEY = pygame.K_l
- def move_line():
- global line_position, line_direction
- if not button_pressed:
- line_position += line_speed * line_direction
- if line_position <= 0 or line_position >= SCREEN_WIDTH:
- line_direction *= -1
- line_position += line_speed * line_direction
- def check_game_over():
- global game_over
- if line_position <= 0 or line_position >= SCREEN_WIDTH:
- game_over = True
- def draw_game():
- screen.fill(BLACK)
- pygame.draw.line(screen, WHITE, (line_position, 0), (line_position, SCREEN_HEIGHT), LINE_WIDTH)
- pygame.draw.rect(screen, RED if line_direction == 1 else GREEN, (0, 0, line_position, SCREEN_HEIGHT), 0)
- pygame.draw.rect(screen, GREEN if line_direction == 1 else RED, (line_position, 0, SCREEN_WIDTH - line_position, SCREEN_HEIGHT), 0)
- if game_over:
- font = pygame.font.Font(None, 74)
- text = font.render("Game Over!", True, WHITE)
- text_rect = text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2))
- screen.blit(text, text_rect)
- pygame.display.flip()
- # Main game loop
- running = True
- while running:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- running = False
- elif event.type == pygame.KEYDOWN:
- if event.key == A_KEY and line_direction == -1:
- button_pressed = True
- elif event.key == L_KEY and line_direction == 1:
- button_pressed = True
- elif event.type == pygame.KEYUP:
- if event.key in [A_KEY, L_KEY]:
- button_pressed = False
- if not game_over:
- move_line()
- check_game_over()
- draw_game()
- clock.tick(FPS)
- pygame.quit()
-
- Llama 3.2 90B (on Groq)
- import pygame
- import random
- import sys
- # Initialize Pygame
- pygame.init()
- # Set up some constants
- WIDTH, HEIGHT = 800, 600
- LINE_COLOR = (255, 255, 255)
- PLAYER_A_COLOR = (0, 0, 255)
- PLAYER_L_COLOR = (255, 0, 0)
- # Set up the display
- screen = pygame.display.set_mode((WIDTH, HEIGHT))
- # Set up the font
- font = pygame.font.Font(None, 36)
- # Set up the clock
- clock = pygame.time.Clock()
- # Set up the game variables
- line_x = WIDTH // 2
- player_a_score = WIDTH // 2
- player_l_score = WIDTH // 2
- moving = False
- direction = 0
- # Game loop
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- elif event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a and moving and direction == -1:
- moving = False
- elif event.key == pygame.K_l and moving and direction == 1:
- moving = False
- # Move the line
- if not moving and random.random() < 0.05:
- moving = True
- direction = random.choice([-1, 1])
- if moving:
- line_x += direction * 5
- if line_x < 0:
- line_x = 0
- player_a_score = 0
- player_l_score = WIDTH
- moving = False
- elif line_x > WIDTH:
- line_x = WIDTH
- player_a_score = WIDTH
- player_l_score = 0
- moving = False
- # Draw everything
- screen.fill((0, 0, 0))
- pygame.draw.line(screen, LINE_COLOR, (line_x, 0), (line_x, HEIGHT), 5)
- pygame.draw.rect(screen, PLAYER_A_COLOR, (0, 0, line_x, HEIGHT))
- pygame.draw.rect(screen, PLAYER_L_COLOR, (line_x, 0, WIDTH - line_x, HEIGHT))
- a_text = font.render(f"A: {player_a_score}", True, (255, 255, 255))
- l_text = font.render(f"L: {player_l_score}", True, (255, 255, 255))
- screen.blit(a_text, (10, 10))
- screen.blit(l_text, (WIDTH - 100, 10))
- # Check for game over
- if player_a_score == 0 or player_l_score == 0:
- if player_a_score == 0:
- screen.fill((0, 0, 0))
- text = font.render("L wins!", True, (255, 255, 255))
- screen.blit(text, (WIDTH // 2 - 50, HEIGHT // 2))
- else:
- screen.fill((0, 0, 0))
- text = font.render("A wins!", True, (255, 255, 255))
- screen.blit(text, (WIDTH // 2 - 50, HEIGHT // 2))
- pygame.display.flip()
- pygame.time.wait(2000)
- break
- # Update the display
- pygame.display.flip()
- # Cap the frame rate
- clock.tick(60)
- # Quit Pygame
- pygame.quit()
Add Comment
Please, Sign In to add comment
Advertisement