Пример #1
0
def mousePressed():
    pressed = world.getBody(mouseX, mouseY)
    if pressed == boxButton:
        myBox = FBox(40, 40)
        myBox.setPosition(width/4, 200)
        myBox.setRotation(random(TWO_PI))
        myBox.setVelocity(0, 200)
        myBox.setFillColor(bodyColor)
        myBox.setNoStroke()
        world.add(myBox)
    elif pressed == circleButton:
        myCircle = FCircle(40)
        myCircle.setPosition(2*width/4, 200)
        myCircle.setRotation(random(TWO_PI))
        myCircle.setVelocity(0, 200)
        myCircle.setFillColor(bodyColor)
        myCircle.setNoStroke()
        world.add(myCircle)
    elif pressed == polyButton:
        myPoly = FPoly()
        myPoly.vertex(20, 20)
        myPoly.vertex(-20, 20)
        myPoly.vertex(0, -20)
        myPoly.setPosition(3*width/4, 200)
        myPoly.setRotation(random(TWO_PI))
        myPoly.setVelocity(0, 200)
        myPoly.setFillColor(bodyColor)
        myPoly.setNoStroke()
        world.add(myPoly)