def setup(): global world size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setGravity(0, 0) world.setEdges() world.remove(world.left) world.remove(world.top) world.remove(world.bottom) for i in range(ballCount): b = FCircle(25) b.setPosition(40, map(i, 0, ballCount - 1, 40, height - 40)) b.setDensity(map(i, 0, ballCount - 1, 0.1, 0.9)) b.setVelocity(100, 0) b.setDamping(0.0) b.setNoStroke() b.setFill(map(i, 0, ballCount - 1, 120, 0)) world.add(b) for i in range(ballCount): b = FCircle(25) b.setPosition(width / 2, map(i, 0, ballCount - 1, 40, height - 40)) b.setVelocity(0, 0) b.setDamping(0.0) b.setDensity(0.9) b.setNoStroke() b.setFill(125, 80, 120) world.add(b)
def setup(): global world size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setGravity(0, 0) world.setEdges() world.remove(world.left) world.remove(world.top) world.remove(world.bottom) for i in range(ballCount): b = FCircle(25) b.setPosition(40, map(i, 0, ballCount-1, 40, height-40)) b.setDensity(map(i, 0, ballCount-1, 0.1, 0.9)) b.setVelocity(100, 0) b.setDamping(0.0) b.setNoStroke() b.setFill(map(i, 0, ballCount-1, 120, 0)) world.add(b) for i in range(ballCount): b = FCircle(25) b.setPosition(width/2, map(i, 0, ballCount-1, 40, height-40)) b.setVelocity(0, 0) b.setDamping(0.0) b.setDensity(0.9) b.setNoStroke() b.setFill(125, 80, 120) world.add(b)
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 mousePressed(): radius = random(10, 40) bola = FCircle(radius) bola.setPosition(mouseX, mouseY) bola.setDensity(0.2) bola.setFill(120, 120, 190) bola.setNoStroke() world.add(bola)
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 draw(): background(255) if frameCount % 8 == 0: b = FCircle(random(5, 20)) b.setPosition(random(0 + 10, width - 10), 50) b.setVelocity(0, 200) b.setRestitution(0) b.setNoStroke() b.setFill(200, 30, 90) world.add(b) pala.setPosition(mouseX, height - 40) world.draw() world.step()
def draw(): background(255) if frameCount % 8 == 0: b = FCircle(random(5, 20)) b.setPosition(random(0+10, width-10), 50) b.setVelocity(0, 200) b.setRestitution(0) b.setNoStroke() b.setFill(200, 30, 90) world.add(b) pala.setPosition(mouseX, height - 40) world.draw() world.step()
def draw(): background(255) if frameCount % 50 == 0: sz = random(30, 60) b = FCircle(sz) b.setPosition(random(0 + 30, width - 30), 50) b.setVelocity(0, 100) b.setRestitution(0.7) b.setDamping(0.01) b.setNoStroke() b.setFill(200, 30, 90) world.add(b) world.draw() world.step()
def draw(): fill(0, 100) noStroke() rect(0, 0, width, height) if frameCount % 24 == 0: bolita = FCircle(8) bolita.setNoStroke() bolita.setFill(255) bolita.setPosition(100, 20) bolita.setVelocity(0, 400) bolita.setRestitution(0.9) bolita.setDamping(0) mundo.add(bolita) mundo.step() mundo.draw(this)
def draw(): fill(0, 100) noStroke() rect(0, 0, width, height) if frameCount % 24 == 0: bolita = FCircle(8) bolita.setNoStroke() bolita.setFill(255) bolita.setPosition(100, 20) bolita.setVelocity(0, 400) bolita.setRestitution(0.9) bolita.setDamping(0) mundo.add(bolita) mundo.step() mundo.draw(this)
def setup(): global world size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setEdges() world.remove(world.left) world.remove(world.right) world.remove(world.top) world.setEdgesRestitution(0.0) for i in range(ballCount): b = FCircle(25) b.setPosition(map(i, 0, ballCount - 1, 40, width - 40), height / 6) b.setRestitution(map(i, 0, ballCount - 1, 0.0, 1.0)) b.setNoStroke() b.setFill(map(i, 0, ballCount - 1, 60, 255), 80, 120) world.add(b)
def setup(): global world size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setEdges() world.remove(world.left) world.remove(world.right) world.remove(world.top) world.setEdgesRestitution(0.0) for i in range(ballCount): b = FCircle(25) b.setPosition(map(i, 0, ballCount-1, 40, width-40), height/6) b.setRestitution(map(i, 0, ballCount-1, 0.0, 1.0)) b.setNoStroke() b.setFill(map(i, 0, ballCount-1, 60, 255), 80, 120) world.add(b)