Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import sys
- # Initialize Pygame
- pygame.init()
- # Set up display
- width, height = 800, 600
- screen = pygame.display.set_mode((width, height))
- pygame.display.set_caption("Mechanical Arm Thrusting")
- # Define colors
- white = (255, 255, 255)
- # Define mechanical arm parameters
- arm_length = 100
- arm_thickness = 20
- joint_radius = 10
- thrust_distance = 50
- thrust_speed = 5
- # Initial arm angles
- base_angle = 0
- arm_angle = 45
- # Main game loop
- clock = pygame.time.Clock()
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- sys.exit()
- # Update arm angles
- arm_angle += thrust_speed
- if arm_angle >= 135 or arm_angle <= 45:
- thrust_speed = -thrust_speed
- # Calculate arm positions
- base_x, base_y = width // 2, height // 2
- arm_x = base_x + arm_length * pygame.math.Vector2(1, 0).rotate(base_angle)
- arm_y = base_y + arm_length * pygame.math.Vector2(1, 0).rotate(base_angle + arm_angle)
- # Draw background
- screen.fill(white)
- # Draw base joint
- pygame.draw.circle(screen, white, (int(base_x), int(base_y)), joint_radius)
- # Draw arm
- pygame.draw.line(screen, white, (base_x, base_y), (arm_x, arm_y), arm_thickness)
- # Update display
- pygame.display.flip()
- # Cap the frame rate
- clock.tick(3)
Advertisement
Comments
-
- No love line has errors pydroid tells me. Is it lying toe trying to gete to commit suicide or are you?
Add Comment
Please, Sign In to add comment