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!
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement