Python物理引擎的杠杆演示

from pyphysicssandbox import *

WIN_WIDTH = 500
WIN_HT = 600
window("Python物理引擎的杠杆演示", WIN_WIDTH, WIN_HT)
gravity(0.0, 10.0)

# 黑色的地板
base = static_box((0, 500), WIN_WIDTH, 10)
base.color = Color("black")

# 绿色的三角形支掌点
triangle = polygon(((250, 450), (275, 500), (225, 500)))
triangle.color = Color("green")

# 深蓝色的杠杆
lever = polygon(((50, 390), (65, 390), (65, 430), (450, 430), (450, 450), (50, 450)))
lever.color = Color("darkblue")
lever.elasticity = 0.90

ball1 = ball((90, 325), 15)
ball1.color = Color("magenta")
ball1.wrap = True             #  超过边界就会从反方向冒出来

ball4 = ball((130, 325), 15)
ball4.color = Color("magenta")
ball4.wrap = True

ball5 = ball((160, 325), 15)
ball5.color = Color("magenta")
ball5.wrap = True

# 从屏幕顶上掉来下的非常重的球
ball2 = ball((425, -200), 20, 200000)
ball2.color = Color("darkgreen")

text = text((90, 250), "Catapult")

run(True)