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, -300) l = FPoly() l.vertex(width/2-hole/2, 0) l.vertex(0, 0) l.vertex(0, height) l.vertex(0+sideMargin, height) l.vertex(0+sideMargin, height-bottomMargin) l.vertex(width/2-hole/2, topMargin) l.setStatic(True) l.setFill(0) l.setFriction(0) world.add(l) r = FPoly() r.vertex(width/2+hole/2, 0) r.vertex(width, 0) r.vertex(width, height) r.vertex(width-sideMargin, height) r.vertex(width-sideMargin, height-bottomMargin) r.vertex(width/2+hole/2, topMargin) r.setStatic(True) r.setFill(0) r.setFriction(0) world.add(r)
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, pop, cage size(400, 400) smooth() Fisica.init(this) Fisica.setScale(10) world = FWorld() world.setEdges() world.remove(world.top) pop = createPop() pop.setPosition(width/2, height/2) pop.setBullet(True) world.add(pop) cage = createCage() cage.setPosition(width/2, height/2) cage.setRotation(PI/6) cage.setBullet(True) world.add(cage) for _ in range(10): c = FCircle(7) c.setPosition(width/2-10+random(-5, 5), height/2-10+random(-5, 5)) c.setBullet(True) c.setNoStroke() c.setFillColor(color(0xFF, 0x92, 0x03)) world.add(c) rectMode(CENTER)
def setup(): global world size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setGravity(0, -300) l = FPoly() l.vertex(width / 2 - hole / 2, 0) l.vertex(0, 0) l.vertex(0, height) l.vertex(0 + sideMargin, height) l.vertex(0 + sideMargin, height - bottomMargin) l.vertex(width / 2 - hole / 2, topMargin) l.setStatic(True) l.setFill(0) l.setFriction(0) world.add(l) r = FPoly() r.vertex(width / 2 + hole / 2, 0) r.vertex(width, 0) r.vertex(width, height) r.vertex(width - sideMargin, height) r.vertex(width - sideMargin, height - bottomMargin) r.vertex(width / 2 + hole / 2, topMargin) r.setStatic(True) r.setFill(0) r.setFriction(0) world.add(r)
def setup(): global world, pop, cage size(400, 400) smooth() Fisica.init(this) Fisica.setScale(10) world = FWorld() world.setEdges() world.remove(world.top) pop = createPop() pop.setPosition(width / 2, height / 2) pop.setBullet(True) world.add(pop) cage = createCage() cage.setPosition(width / 2, height / 2) cage.setRotation(PI / 6) cage.setBullet(True) world.add(cage) for _ in range(10): c = FCircle(7) c.setPosition(width / 2 - 10 + random(-5, 5), height / 2 - 10 + random(-5, 5)) c.setBullet(True) c.setNoStroke() c.setFillColor(color(0xFF, 0x92, 0x03)) world.add(c) rectMode(CENTER)
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)
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 size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setGravity(0, 100) world.setEdges()
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 size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setEdges() world.setGravity(0, 0) for _ in range(spiderCount): createSpider()
def setup(): global mundo size(400, 400) smooth() Fisica.init(this) mundo = FWorld() mundo.setGravity(0, 200) frameRate(24) background(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 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 setup(): global world size(400, 400) smooth() Fisica.init(this) world = FWorld() world.setGravity(0, 800) world.setEdges() world.remove(world.left) world.remove(world.right) world.remove(world.top) world.setEdgesRestitution(0.5)
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)
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)
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)
def setup(): global world size(400, 400) smooth() Fisica.init(this) font = loadFont("FreeMonoBold-24.vlw") textFont(font, 24) world = FWorld() world.setEdges(this, color(120)) world.remove(world.top) world.setGravity(0, 500) t = Texto("Type and ENTER") t.setPosition(width/2, height/2) t.setRotation(random(-1, 1)) t.setFill(255) t.setNoStroke() t.setRestitution(0.75) world.add(t)
def setup(): global world size(400, 400) smooth() Fisica.init(this) font = loadFont("FreeMonoBold-24.vlw") textFont(font, 24) world = FWorld() world.setEdges(this, color(120)) world.remove(world.top) world.setGravity(0, 500) t = Texto("Type and ENTER") t.setPosition(width / 2, height / 2) t.setRotation(random(-1, 1)) t.setFill(255) t.setNoStroke() t.setRestitution(0.75) world.add(t)
def test_atacar(self): self.guerreroA.add_habilidad(Fisica("Testarazo", 50, 50)) self.guerreroA.atacar(self.guerreroB, self.guerreroA.habilidades[0]) self.assertEqual(self.guerreroB.vida_restante,20) self.assertEqual(self.guerreroA.furia_restante,50) with self.assertRaises(Exception) as context: self.guerreroA.atacar(self.guerreroB, self.guerreroA.habilidades[0]) self.assertTrue(context, "El personaje a muerto" ) with self.assertRaises(Exception) as context: self.guerreroA.atacar(self.guerreroB, self.guerreroA.habilidades[0]) self.assertTrue(context, "No tienes suficiente furia" )
from pessoa import Pessoa from fisica import Fisica from juridica import Juridica p = Pessoa("Julia", "Av. Ipiranga") f = Fisica("Maria", "Av. Protásio Alves", "111.222.333-44") j = Juridica("Mercado do João", "Av. A, 132", "11.222.333/0001-44") p.imprimir() f.imprimir() j.imprimir()
def test_add_fisica(self): self.guerreroA.add_habilidad(Fisica("Testarazo", 50, 15)) self.assertEqual("Testarazo", self.guerreroA.habilidades[0].nombre) with self.assertRaises(Exception) as context: self.guerreroA.add_habilidad(Magia("Bola de fuego", 50, 15)) self.assertTrue(context, "La habilidad tiene que ser de tipo fisica" )
def setUp(self): print("Iniciando test de la clase Fisica") self.fisicaA = Fisica("Testarazo",10,15) self.fisicaB = Fisica("Golpe certero",20,25)