何かを動かす

日経ソフトウエア 2020年 3 月号, pp.42ff.
update()による描画更新頻度は、計算が間に合いさえすれば基本的には60fpsとの由。

import pgzrun
import math

WIDTH = 600
HEIGHT = 400
CX = WIDTH / 2
CY = HEIGHT / 2

rad = 0

def draw():
    screen.fill("dodgerblue")
    screen.draw.circle((WIDTH/2, CY - CY * math.sin(rad)), 20, "black")
    
def update():
    global rad
    rad += 0.05

pgzrun.go()

f:id:ti-nspire:20201204070026p:plain