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