Search in sources :

Example 1 with World

use of org.jbox2d.dynamics.World in project Bytecoder by mirkosertic.

the class JBox2DTest method testNewWorld2.

@Test
public void testNewWorld2() {
    World world = new World(new Vec2(0, -9.8f));
    Assert.assertFalse(world.isLocked());
}
Also used : Vec2(org.jbox2d.common.Vec2) World(org.jbox2d.dynamics.World) Test(org.junit.Test)

Example 2 with World

use of org.jbox2d.dynamics.World in project Bytecoder by mirkosertic.

the class JBox2DTest method testNewWorld.

@Test
public void testNewWorld() {
    World world = new World(new Vec2(0, -9.8f));
    BodyDef axisDef = new BodyDef();
    axisDef.type = BodyType.STATIC;
    axisDef.position = new Vec2(3, 3);
    Body axis = world.createBody(axisDef);
    CircleShape axisShape = new CircleShape();
    axisShape.setRadius(0.02f);
    axisShape.m_p.set(0, 0);
// FixtureDef axisFixture = new FixtureDef();
// axisFixture.shape = axisShape;
// axis.createFixture(axisFixture);
}
Also used : CircleShape(org.jbox2d.collision.shapes.CircleShape) Vec2(org.jbox2d.common.Vec2) World(org.jbox2d.dynamics.World) BodyDef(org.jbox2d.dynamics.BodyDef) Body(org.jbox2d.dynamics.Body) Test(org.junit.Test)

Example 3 with World

use of org.jbox2d.dynamics.World in project HackerHop by nicovank.

the class PlatformTest method distanceTest.

@Test
void distanceTest() {
    World world = new World(new Vec2(0, -50));
    float x1 = 10;
    float y1 = 20;
    float x2 = 30;
    float y2 = 40;
    Platform b = new Platform(x2, y2, world);
    Platform a = new Platform(x1, y1, world);
    double distance = Math.sqrt(Math.pow((30 - 10), 2) + Math.pow((40 - 20), 2));
    assertEquals(distance, b.distanceTo(a));
}
Also used : Platform(com.hackerhop.game.core.objects.platforms.Platform) Vec2(org.jbox2d.common.Vec2) World(org.jbox2d.dynamics.World) Test(org.junit.jupiter.api.Test)

Example 4 with World

use of org.jbox2d.dynamics.World in project HackerHop by nicovank.

the class PlayerTest method withinBoundsWhenGameStartsTest.

@Test
void withinBoundsWhenGameStartsTest() {
    World world = new World(new Vec2(0, -50));
    Vec2 position = new Vec2(0, 10);
    Player p = new Player(world, position);
    float x = p.getBody().getPosition().x;
    float y = p.getBody().getPosition().y;
    assertTrue(x >= 0 && x <= 54);
    assertTrue(y >= 0 && y <= 72);
}
Also used : Vec2(org.jbox2d.common.Vec2) World(org.jbox2d.dynamics.World) Test(org.junit.jupiter.api.Test)

Example 5 with World

use of org.jbox2d.dynamics.World in project HackerHop by nicovank.

the class PlayerTest method characterTest.

// testing player character
@Test
void characterTest() {
    World world = new World(new Vec2(0, -50));
    Vec2 position = new Vec2(0, 10);
    Character character = Character.ROB;
    Player p = new Player(world, position, character);
    assertSame(p.getCharacter(), character.ROB);
}
Also used : Vec2(org.jbox2d.common.Vec2) World(org.jbox2d.dynamics.World) Test(org.junit.jupiter.api.Test)

Aggregations

Vec2 (org.jbox2d.common.Vec2)9 World (org.jbox2d.dynamics.World)9 Test (org.junit.jupiter.api.Test)6 Test (org.junit.Test)3 CircleShape (org.jbox2d.collision.shapes.CircleShape)2 Body (org.jbox2d.dynamics.Body)2 BodyDef (org.jbox2d.dynamics.BodyDef)2 Platform (com.hackerhop.game.core.objects.platforms.Platform)1 ManifoldPoint (org.jbox2d.collision.ManifoldPoint)1 PolygonShape (org.jbox2d.collision.shapes.PolygonShape)1 Shape (org.jbox2d.collision.shapes.Shape)1 FixtureDef (org.jbox2d.dynamics.FixtureDef)1