jaldpsd
Sep 26th, 2024
58
0
Never
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!
  1. Llama 3.2 90B (on Groq)
  2.  
  3. import pygame
  4. import random
  5. import sys
  6.  
  7. # Initialize Pygame
  8. pygame.init()
  9.  
  10. # Set up some constants
  11. WIDTH, HEIGHT = 800, 600
  12. LINE_COLOR = (255, 255, 255)
  13. PLAYER_A_COLOR = (0, 0, 255)
  14. PLAYER_L_COLOR = (255, 0, 0)
  15.  
  16. # Set up the display
  17. screen = pygame.display.set_mode((WIDTH, HEIGHT))
  18.  
  19. # Set up the font
  20. font = pygame.font.Font(None, 36)
  21.  
  22. # Set up the clock
  23. clock = pygame.time.Clock()
  24.  
  25. # Set up the game variables
  26. line_x = WIDTH // 2
  27. player_a_score = WIDTH // 2
  28. player_l_score = WIDTH // 2
  29. moving = False
  30. direction = 0
  31.  
  32. # Game loop
  33. while True:
  34. for event in pygame.event.get():
  35. if event.type == pygame.QUIT:
  36. pygame.quit()
  37. sys.exit()
  38. elif event.type == pygame.KEYDOWN:
  39. if event.key == pygame.K_a and moving and direction == -1:
  40. moving = False
  41. elif event.key == pygame.K_l and moving and direction == 1:
  42. moving = False
  43.  
  44. # Move the line
  45. if not moving and random.random() < 0.05:
  46. moving = True
  47. direction = random.choice([-1, 1])
  48. if moving:
  49. line_x += direction * 5
  50. if line_x < 0:
  51. line_x = 0
  52. player_a_score = 0
  53. player_l_score = WIDTH
  54. moving = False
  55. elif line_x > WIDTH:
  56. line_x = WIDTH
  57. player_a_score = WIDTH
  58. player_l_score = 0
  59. moving = False
  60.  
  61. # Draw everything
  62. screen.fill((0, 0, 0))
  63. pygame.draw.line(screen, LINE_COLOR, (line_x, 0), (line_x, HEIGHT), 5)
  64. pygame.draw.rect(screen, PLAYER_A_COLOR, (0, 0, line_x, HEIGHT))
  65. pygame.draw.rect(screen, PLAYER_L_COLOR, (line_x, 0, WIDTH - line_x, HEIGHT))
  66. a_text = font.render(f"A: {player_a_score}", True, (255, 255, 255))
  67. l_text = font.render(f"L: {player_l_score}", True, (255, 255, 255))
  68. screen.blit(a_text, (10, 10))
  69. screen.blit(l_text, (WIDTH - 100, 10))
  70.  
  71. # Check for game over
  72. if player_a_score == 0 or player_l_score == 0:
  73. if player_a_score == 0:
  74. screen.fill((0, 0, 0))
  75. text = font.render("L wins!", True, (255, 255, 255))
  76. screen.blit(text, (WIDTH // 2 - 50, HEIGHT // 2))
  77. else:
  78. screen.fill((0, 0, 0))
  79. text = font.render("A wins!", True, (255, 255, 255))
  80. screen.blit(text, (WIDTH // 2 - 50, HEIGHT // 2))
  81. pygame.display.flip()
  82. pygame.time.wait(2000)
  83. break
  84.  
  85. # Update the display
  86. pygame.display.flip()
  87.  
  88. # Cap the frame rate
  89. clock.tick(60)
  90.  
  91. # Quit Pygame
  92. pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment