import pygame import sys import math # Initialize Pygame pygame.init() # Set up display width, height = 800, 600 screen = pygame.display.set_mode((width, height)) pygame.display.set_caption("Grapple Hook Game") # Colors white = (255, 255, 255) red = (255, 0, 0) # Player variables player_pos = [width // 2, height // 2] player_speed = 2 # Adjust player movement speed player_radius = 15 # Grapple hook variables grapple_hook_length = 200 grapple_hook_angle = 0 grapple_hook_speed = 2 # Adjust grapple hook rotation speed grapple_hook_attached = False # Main game loop while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() keys = pygame.key.get_pressed() # Handle player movement if keys[pygame.K_LEFT] and player_pos[0] > 0: player_pos[0] -= player_speed if keys[pygame.K_RIGHT] and player_pos[0] < width: player_pos[0] += player_speed if keys[pygame.K_UP] and player_pos[1] > 0: player_pos[1] -= player_speed if keys[pygame.K_DOWN] and player_pos[1] < height: player_pos[1] += player_speed # ... # Handle grapple hook if not grapple_hook_attached: if keys[pygame.K_SPACE]: grapple_hook_attached = True else: grapple_hook_angle += grapple_hook_speed grapple_hook_x = player_pos[0] + grapple_hook_length * math.cos(math.radians(grapple_hook_angle)) grapple_hook_y = player_pos[1] + grapple_hook_length * math.sin(math.radians(grapple_hook_angle)) pygame.draw.line(screen, red, player_pos, (grapple_hook_x, grapple_hook_y), 5) pygame.draw.circle(screen, red, (int(grapple_hook_x), int(grapple_hook_y)), 10) # Draw the grapple hook point # ... # Clear the screen screen.fill(white) # Draw the player pygame.draw.circle(screen, red, (int(player_pos[0]), int(player_pos[1])), player_radius) # Update the display pygame.display.flip()