如何通过向上移动来简单地为这些弧设置动画?
import random
import pygame
import math
WIDTH = 700
HEIGHT = 500
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
BLUE = (0, 0, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
BROWN = (101, 67, 33)
YELLOW = (255, 255, 0)
PI = math.pi
def draw():
screen.fill(BLUE)
chimney_smoke(400, 90, 50, 100)
我不确定要在更新功能中加入什么:
def update():
def chimney_smoke(x, y, w, h):
pygame.draw.arc(screen.surface, BLACK, [x, y, w ,h], PI/2, PI, 2)
pygame.draw.arc(screen.surface, BLACK, [x, y, w, h], 0, PI/2, 2)
pygame.draw.arc(screen.surface, BLACK, [x, y, w, h], 3*PI/2, 2*PI, 2)
pygame.draw.arc(screen.surface, BLACK, [x, y, w, h], PI, 3*PI/2, 2)
我做了很多尝试,但似乎无法得到它。这是为了上课,我被困住了。任何帮助将不胜感激!
答案 0 :(得分:0)
您要做的是将硬编码的90
替换为变量,每次PyGame Zero调用update
函数时都可以更新。像这样:
smoke_y = 90
def update():
global smoke_y
smoke_y -= 1
def draw():
screen.fill(BLUE)
chimney_smoke(400, y, 50, 100)
当然你可能不想以每帧1个像素的速度精确移动,你可能想要为你到达屏幕边缘时发生的事情添加一些逻辑,但这应该足以让你走