Pygame 添加手臂并摇摆它

问题描述

我需要有关代码的帮助。如您所见,我有身体代码,但我需要如图所示(白色)为其添加手臂,并希望它摆动(例如上下移动)并在窗口向右移动时在窗口周围移动现在。任何人都可以在 Pygame 中帮助我吗?

附上图片代码

enter image description here

import pygame

BLACK = (0,0)
WHITE = (255,255,255)
GREEN = (0,0)
RED = (255,0)
YELLOW = (255,215,0)
BLUE = (0,255)
LIGHT_BLUE = (0,191,255)

pygame.init()

size = [1200,1000]
screen = pygame.display.set_mode(size)
pygame.display.set_caption("D")

done = False

clock = pygame.time.Clock()

rect_x = 50
rect_y = 50

rect_change_x = 2
rect_change_y = 2

while not done:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

    rect_x += rect_change_x
    rect_y += rect_change_y

    if rect_y > 700 or rect_y < 0:
        rect_change_y = rect_change_y * -1
    if rect_x > 900 or rect_x < 0:
        rect_change_x = rect_change_x * -1

    # --- Drawing

    screen.fill(BLACK)

    pygame.draw.rect(screen,YELLOW,[rect_x,rect_y,150,150])
    pygame.draw.circle(screen,BLACK,[rect_x + 50,rect_y + 50],27,2)
    pygame.draw.circle(screen,[rect_x + 100,WHITE,[rect_x +50,25)
    pygame.draw.circle(screen,25)
    pygame.draw.line(screen,[rect_x+50,rect_y+25],rect_y+15],2)
    pygame.draw.line(screen,[rect_x+35,[rect_x+30,[rect_x+60,[rect_x+65,[rect_x+100,[rect_x+85,[rect_x+80,[rect_x+110,[rect_x+115,rect_y+75],[rect_x + 75,rect_y + 75],10,LIGHT_BLUE,[rect_x +60,13)
    pygame.draw.circle(screen,[rect_x +90,5)
    pygame.draw.circle(screen,5)

    my_rect1 = pygame.Rect(rect_x + 35,rect_y + 100,90,30)
    pygame.draw.ellipse(screen,my_rect1)

    my_rect = pygame.Rect(rect_x + 60,rect_y + 120,20,10)
    pygame.draw.ellipse(screen,RED,my_rect)

    my_rect = pygame.Rect(rect_x + 80,my_rect)

    pygame.draw.rect(screen,rect_y+100,10])
    pygame.draw.rect(screen,10])

    clock.tick(60)

    pygame.display.flip()

pygame.quit()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)