def setup():
    global boxButton, circleButton, polyButton, world

    size(400, 400)
    smooth()
    Fisica.init(this)
    world = FWorld()
    world.setEdges()
    world.remove(world.left)
    world.remove(world.right)
    world.remove(world.top)
    boxButton = FBox(40, 40)
    boxButton.setPosition(width/4, 100)
    boxButton.setStatic(True)
    boxButton.setFillColor(buttonColor)
    boxButton.setNoStroke()
    world.add(boxButton)
    circleButton = FCircle(40)
    circleButton.setPosition(2*width/4, 100)
    circleButton.setStatic(True)
    circleButton.setFillColor(buttonColor)
    circleButton.setNoStroke()
    world.add(circleButton)
    polyButton = FPoly()
    polyButton.vertex(20, 20)
    polyButton.vertex(-20, 20)
    polyButton.vertex(0, -20)
    polyButton.setPosition(3*width/4, 100)
    polyButton.setStatic(True)
    polyButton.setFillColor(buttonColor)
    polyButton.setNoStroke()
    world.add(polyButton)
Exemple #2
0
 def draw(self, applet):
     FBox.draw(self, applet)
     self.preDraw(applet)
     fill(0)
     stroke(0)
     textAlign(CENTER)
     text(self.texto, 0, self.textOffset)
     self.postDraw(applet)
Exemple #3
0
 def draw(self, applet):
     FBox.draw(self, applet)
     self.preDraw(applet)
     fill(0)
     stroke(0)
     textAlign(CENTER)
     text(self.texto, 0, self.textOffset)
     self.postDraw(applet)
Exemple #4
0
def mousePressed():
    global caja, x, y
    caja = FBox(4, 4)
    caja.setStaticBody(True)
    caja.setStroke(255)
    caja.setFill(255)
    caja.setRestitution(0.9)
    mundo.add(caja)

    x = mouseX
    y = mouseY
Exemple #5
0
def setup():
    global world, pala
    size(400, 400)
    smooth()
    Fisica.init(this)
    world = FWorld()
    pala = FBox(50, 20)
    pala.setPosition(width / 2, height - 40)
    pala.setStatic(True)
    pala.setFill(0)
    pala.setRestitution(0)
    world.add(pala)
def createPop():
    b = FBox(6, 60)
    b.setFillColor(color(0x1F, 0x71, 0x6B))
    b.setNoStroke()
    c = FCircle(20)
    c.setPosition(0, -30)
    c.setFillColor(color(0xFF, 0x00, 0x51))
    c.setNoStroke()

    result = FCompound()
    result.addBody(b)
    result.addBody(c)

    return result
def mousePressed():
    global caja, x, y
    caja = FBox(4, 4)
    caja.setStaticBody(True)
    caja.setStroke(255)
    caja.setFill(255)
    caja.setRestitution(0.9)
    mundo.add(caja)

    x = mouseX
    y = mouseY
Exemple #8
0
def setup():
    global puenteY, world

    size(400, 400)
    smooth()
    puenteY = height / 3
    Fisica.init(this)
    world = FWorld()
    bola = FCircle(40)
    bola.setPosition(width / 3, puenteY - 10)
    bola.setDensity(0.2)
    bola.setFill(120, 120, 190)
    bola.setNoStroke()
    world.add(bola)
    for i in range(stepCount):
        box = FBox(boxWidth, 10)
        box.setPosition(map(i, 0, stepCount - 1, boxWidth, width - boxWidth),
                        puenteY)
        box.setNoStroke()
        box.setFill(120, 200, 190)
        world.add(box)
        steps.append(box)

    for i in range(1, stepCount):
        junta = FDistanceJoint(steps[i - 1], steps[i])
        junta.setAnchor1(boxWidth / 2, 0)
        junta.setAnchor2(-boxWidth / 2, 0)
        junta.setFrequency(frequency)
        junta.setDamping(damping)
        junta.setFill(0)
        junta.calculateLength()
        world.add(junta)

    left = FCircle(10)
    left.setStatic(True)
    left.setPosition(0, puenteY)
    left.setDrawable(False)
    world.add(left)
    right = FCircle(10)
    right.setStatic(True)
    right.setPosition(width, puenteY)
    right.setDrawable(False)
    world.add(right)
    juntaPrincipio = FDistanceJoint(steps[0], left)
    juntaPrincipio.setAnchor1(-boxWidth / 2, 0)
    juntaPrincipio.setAnchor2(0, 0)
    juntaPrincipio.setFrequency(frequency)
    juntaPrincipio.setDamping(damping)
    juntaPrincipio.calculateLength()
    juntaPrincipio.setFill(0)
    world.add(juntaPrincipio)
    juntaFinal = FDistanceJoint(steps[stepCount - 1], right)
    juntaFinal.setAnchor1(boxWidth / 2, 0)
    juntaFinal.setAnchor2(0, 0)
    juntaFinal.setFrequency(frequency)
    juntaFinal.setDamping(damping)
    juntaFinal.calculateLength()
    juntaFinal.setFill(0)
    world.add(juntaFinal)
def setup():
    global world, pala
    size(400, 400)
    smooth()
    Fisica.init(this)
    world = FWorld()
    pala = FBox(50, 20)
    pala.setPosition(width/2, height - 40)
    pala.setStatic(True)
    pala.setFill(0)
    pala.setRestitution(0)
    world.add(pala)
Exemple #10
0
def setup():
    global puenteY, world

    size(400, 400)
    smooth()
    puenteY = height/3
    Fisica.init(this)
    world = FWorld()
    bola = FCircle(40)
    bola.setPosition(width/3, puenteY-10)
    bola.setDensity(0.2)
    bola.setFill(120, 120, 190)
    bola.setNoStroke()
    world.add(bola)
    for i in range(stepCount):
        box = FBox(boxWidth, 10)
        box.setPosition(map(i, 0, stepCount - 1, boxWidth, width-boxWidth), puenteY)
        box.setNoStroke()
        box.setFill(120, 200, 190)
        world.add(box)
        steps.append(box)

    for i in range(1, stepCount):
        junta = FDistanceJoint(steps[i-1], steps[i])
        junta.setAnchor1(boxWidth/2, 0)
        junta.setAnchor2(-boxWidth/2, 0)
        junta.setFrequency(frequency)
        junta.setDamping(damping)
        junta.setFill(0)
        junta.calculateLength()
        world.add(junta)

    left = FCircle(10)
    left.setStatic(True)
    left.setPosition(0, puenteY)
    left.setDrawable(False)
    world.add(left)
    right = FCircle(10)
    right.setStatic(True)
    right.setPosition(width, puenteY)
    right.setDrawable(False)
    world.add(right)
    juntaPrincipio = FDistanceJoint(steps[0], left)
    juntaPrincipio.setAnchor1(-boxWidth/2, 0)
    juntaPrincipio.setAnchor2(0, 0)
    juntaPrincipio.setFrequency(frequency)
    juntaPrincipio.setDamping(damping)
    juntaPrincipio.calculateLength()
    juntaPrincipio.setFill(0)
    world.add(juntaPrincipio)
    juntaFinal = FDistanceJoint(steps[stepCount-1], right)
    juntaFinal.setAnchor1(boxWidth/2, 0)
    juntaFinal.setAnchor2(0, 0)
    juntaFinal.setFrequency(frequency)
    juntaFinal.setDamping(damping)
    juntaFinal.calculateLength()
    juntaFinal.setFill(0)
    world.add(juntaFinal)
Exemple #11
0
def createPop():
    b = FBox(6, 60)
    b.setFillColor(color(0x1F, 0x71, 0x6B))
    b.setNoStroke()
    c = FCircle(20)
    c.setPosition(0, -30)
    c.setFillColor(color(0xFF, 0x00, 0x51))
    c.setNoStroke()

    result = FCompound()
    result.addBody(b)
    result.addBody(c)

    return result
def setup():
    global world, obstacle
    size(400, 400)
    smooth()
    Fisica.init(this)
    world = FWorld()
    obstacle = FBox(150, 150)
    obstacle.setRotation(PI / 4)
    obstacle.setPosition(width / 2, height / 2)
    obstacle.setStatic(True)
    obstacle.setFill(0)
    obstacle.setRestitution(0)
    world.add(obstacle)
Exemple #13
0
def createCage():
    b1 = FBox(10, 110)
    b1.setPosition(50, 0)
    b1.setFill(0)
    b1.setNoStroke()
    b2 = FBox(10, 110)
    b2.setPosition(-50, 0)
    b2.setFill(0)
    b2.setNoStroke()

    b3 = FBox(110, 10)
    b3.setPosition(0, 50)
    b3.setFill(0)
    b3.setNoStroke()

    b4 = FBox(110, 10)
    b4.setPosition(0, -50)
    b4.setFill(0)
    b4.setNoStroke()

    result = FCompound()
    result.addBody(b1)
    result.addBody(b2)
    result.addBody(b3)
    result.addBody(b4)
    return result
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)
Exemple #15
0
 def __init__(self, _texto):
     FBox.__init__(self, textWidth(_texto), textAscent() + textDescent())
     self.texto = _texto
     self.textOffset = textAscent() - self.getHeight()/2
Exemple #16
0
 def __init__(self, _texto):
     FBox.__init__(self, textWidth(_texto), textAscent() + textDescent())
     self.texto = _texto
     self.textOffset = textAscent() - self.getHeight() / 2
Exemple #17
0
def createCage():
    b1 = FBox(10, 110)
    b1.setPosition(50, 0)
    b1.setFill(0)
    b1.setNoStroke()
    b2 = FBox(10, 110)
    b2.setPosition(-50, 0)
    b2.setFill(0)
    b2.setNoStroke()

    b3 = FBox(110, 10)
    b3.setPosition(0, 50)
    b3.setFill(0)
    b3.setNoStroke()

    b4 = FBox(110, 10)
    b4.setPosition(0, -50)
    b4.setFill(0)
    b4.setNoStroke()

    result = FCompound()
    result.addBody(b1)
    result.addBody(b2)
    result.addBody(b3)
    result.addBody(b4)
    return result
Exemple #18
0
def setup():
    global world, obstacle
    size(400, 400)
    smooth()
    Fisica.init(this)
    world = FWorld()
    obstacle = FBox(150,150)
    obstacle.setRotation(PI/4)
    obstacle.setPosition(width/2, height/2)
    obstacle.setStatic(True)
    obstacle.setFill(0)
    obstacle.setRestitution(0)
    world.add(obstacle)