Search in sources :

Example 1 with BasePhysicsManager

use of com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager in project Entitas-Java by Rubentxu.

the class Block method create.

@Override
public GameEntity create(Engine engine, Context<GameEntity> context) {
    BasePhysicsManager physics = engine.getManager(BasePhysicsManager.class);
    BodyBuilder bodyBuilder = physics.getBodyBuilder();
    Body bodyBlock = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(1, 1).friction(0.5f).restitution(0.5f)).type(BodyDef.BodyType.StaticBody).build();
    GameEntity entity = context.createEntity().addRigidBody(bodyBlock).addElement("Platform", "Block");
    return entity;
}
Also used : FixtureDefBuilder(ilargia.egdx.util.FixtureDefBuilder) GameEntity(com.indignado.games.states.game.gen.GameEntity) BasePhysicsManager(com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager) BodyBuilder(ilargia.egdx.util.BodyBuilder) Body(com.badlogic.gdx.physics.box2d.Body)

Example 2 with BasePhysicsManager

use of com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager in project Entitas-Java by Rubentxu.

the class Ground method create.

@Override
public GameEntity create(Engine engine, Context<GameEntity> context) {
    BasePhysicsManager physics = engine.getManager(BasePhysicsManager.class);
    BodyBuilder bodyBuilder = physics.getBodyBuilder();
    Body bodyGround = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(50, 0.5f).friction(0.5f)).build();
    GameEntity entity = ((GameContext) context).createEntity().addRigidBody(bodyGround).addElement("Platform", "Ground");
    return entity;
}
Also used : FixtureDefBuilder(ilargia.egdx.util.FixtureDefBuilder) GameEntity(com.indignado.games.states.game.gen.GameEntity) GameContext(com.indignado.games.states.game.gen.GameContext) BasePhysicsManager(com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager) BodyBuilder(ilargia.egdx.util.BodyBuilder) Body(com.badlogic.gdx.physics.box2d.Body)

Example 3 with BasePhysicsManager

use of com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager in project Entitas-Java by Rubentxu.

the class Mariano method create.

@Override
public GameEntity create(Engine engine, Context<GameEntity> context) {
    BasePhysicsManager physics = engine.getManager(BasePhysicsManager.class);
    BodyBuilder bodyBuilder = physics.getBodyBuilder();
    TextureAtlas textureAtlas = assetsManager.getTextureAtlas(atlas);
    Array<TextureAtlas.AtlasRegion> heroWalking = textureAtlas.findRegions("Andando");
    Array<TextureAtlas.AtlasRegion> heroJump = textureAtlas.findRegions("Saltando");
    Array<TextureAtlas.AtlasRegion> heroFall = textureAtlas.findRegions("Cayendo");
    Array<TextureAtlas.AtlasRegion> heroIdle = textureAtlas.findRegions("Parado");
    Map<String, Animation<TextureRegion>> animationStates = Collections.createMap(String.class, Animation.class);
    animationStates.put("walking", new Animation(0.02f, heroWalking, Animation.PlayMode.LOOP));
    animationStates.put("jump", new Animation(0.02f * 7, heroJump, Animation.PlayMode.NORMAL));
    animationStates.put("fall", new Animation(0.02f * 5, heroFall, Animation.PlayMode.NORMAL));
    animationStates.put("idle", new Animation(0.02f * 4, heroIdle, Animation.PlayMode.LOOP));
    Body bodyPlayer = bodyBuilder.fixture(bodyBuilder.fixtureDefBuilder().boxShape(0.35f, 1).density(1)).type(BodyDef.BodyType.DynamicBody).fixedRotation().position(0, 5).mass(1).build();
    GameEntity entity = ((GameContext) context).getPlayerEntity().addRigidBody(bodyPlayer).addAnimations(animationStates, animationStates.get("idle"), 0).addCharacter("Mariano", StateCharacter.IDLE, false).addMovable(7, 8).addTextureView(null, new Bounds(0.9f, 1.15f), false, false, 1, 1, Color.WHITE);
    return entity;
}
Also used : GameEntity(com.indignado.games.states.game.gen.GameEntity) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) Bounds(com.ilargia.games.logicbrick.data.Bounds) Animation(com.badlogic.gdx.graphics.g2d.Animation) BasePhysicsManager(com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager) BodyBuilder(ilargia.egdx.util.BodyBuilder) Body(com.badlogic.gdx.physics.box2d.Body)

Example 4 with BasePhysicsManager

use of com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager in project Entitas-Java by Rubentxu.

the class Block method create.

@Override
public GameEntity create(Engine engine, Context<GameEntity> context) {
    BasePhysicsManager physics = engine.getManager(BasePhysicsManager.class);
    BodyBuilder bodyBuilder = physics.getBodyBuilder();
    Body bodyBlock = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(1, 1).friction(0.5f).restitution(0.5f)).type(BodyDef.BodyType.StaticBody).build();
    GameEntity entity = context.createEntity().addRigidBody(bodyBlock).addElement("Platform", "Block");
    return entity;
}
Also used : FixtureDefBuilder(ilargia.egdx.util.FixtureDefBuilder) GameEntity(com.indignado.games.states.game.gen.GameEntity) BasePhysicsManager(com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager) BodyBuilder(ilargia.egdx.util.BodyBuilder) Body(com.badlogic.gdx.physics.box2d.Body)

Example 5 with BasePhysicsManager

use of com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager in project Entitas-Java by Rubentxu.

the class Ground method create.

@Override
public GameEntity create(Engine engine, Context<GameEntity> context) {
    BasePhysicsManager physics = engine.getManager(BasePhysicsManager.class);
    BodyBuilder bodyBuilder = physics.getBodyBuilder();
    Body bodyGround = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(50, 0.5f).friction(0.5f)).build();
    GameEntity entity = ((GameContext) context).createEntity().addRigidBody(bodyGround).addElement("Platform", "Ground");
    return entity;
}
Also used : FixtureDefBuilder(ilargia.egdx.util.FixtureDefBuilder) GameEntity(com.indignado.games.states.game.gen.GameEntity) GameContext(com.indignado.games.states.game.gen.GameContext) BasePhysicsManager(com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager) BodyBuilder(ilargia.egdx.util.BodyBuilder) Body(com.badlogic.gdx.physics.box2d.Body)

Aggregations

Body (com.badlogic.gdx.physics.box2d.Body)6 BasePhysicsManager (com.ilargia.games.entitas.egdx.base.managers.BasePhysicsManager)6 GameEntity (com.indignado.games.states.game.gen.GameEntity)6 BodyBuilder (ilargia.egdx.util.BodyBuilder)6 FixtureDefBuilder (ilargia.egdx.util.FixtureDefBuilder)4 GameContext (com.indignado.games.states.game.gen.GameContext)2 Animation (com.badlogic.gdx.graphics.g2d.Animation)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 Bounds (com.ilargia.games.logicbrick.data.Bounds)1 Bounds (com.indignado.games.states.game.data.Bounds)1