Advertisement
This is comment for paste
GPT-4 vs Llama-3 vs Claude
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement