How would I simply animate these arcs by making them move upwards?
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)
I'm not sure what to put into the update function:
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)
I've made many attempts but can't seem to get it. This is for class and I'm stuck. Any help would be greatly appreciated!
What you want to do is replace that hardcoded 90
with a variable, which you can update every time PyGame Zero calls your update
function. Something like this:
smoke_y = 90
def update():
global smoke_y
smoke_y -= 1
def draw():
screen.fill(BLUE)
chimney_smoke(400, y, 50, 100)
Of course you may not want to move at exact the speed of 1 pixel per frame, and you probably want to add some logic for what happens when you hit the edge of the screen, but that should be enough to get you going.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.