Text Size
Text Size
Exit Full Screen
Python Mini
Show
Source Code
View Source Code in Full Screen
Open in New Tab
from processing import * from math import atan2 mb = [] class Goose: def __init__(self): self.vr = 0 self.r = 0 self.x = 400 self.y = 400 def hone(var,target,step): if var < step+target and var > target-step and var != target: var = target elif var > target: var -= step elif var < target: var += step return var def setup(): global gooseImg, g gooseImg = loadImage("http://oyosite.s3.amazonaws.com/userdata/img5/1573577383-59ff7bf2ca292c38749dfaba.png") g = Goose() size(500,500) def mousePressed(): global mb if mouse.button not in mb: mb.append(mouse.button) def mouseReleased(): global mb if mouse.button in mb: mb.remove(mouse.button) def draw(): global g, mb background(10) if ((mouse.x-g.x)**2+(mouse.y-g.y)**2)**.5 <= 50: if 37 in mb: g.vr = atan2((mouse.px-g.x),(mouse.py-g.y))-atan2((mouse.x-g.x),(mouse.y-g.y)) if abs(g.vr) > PI: if g.vr > PI: g.vr -= TAU else: g.vr += TAU noStroke() fill(0,0,200) pushMatrix() translate(250,250) pushMatrix() rotate(g.r) rect(-5,0,10,200) ellipse(0,0,10,10) popMatrix() popMatrix() text(g.r,10,10) g.r += g.vr g.vr = hone(g.vr,0,.01) imageMode(CENTER,CENTER) pushMatrix() translate(g.x,g.y) rotate(g.r) image(gooseImg,0,0,150,125) popMatrix() run()
wheel.py
( around 61 lines python code )
Published By:
luyfru
Published on
2023-09-21T18:53:56Z
Python Mini
- an
OYOclass
application,
own your own class today
.
Run
Result
×
Error message shows here