Search in sources :

Example 1 with FixtureDefBuilder

use of ilargia.egdx.util.FixtureDefBuilder in project Entitas-Java by Rubentxu.

the class GameSceneState method initialize.

@Override
public void initialize() {
    atlas = assetsManager.getTextureAtlas(SPRITE_ATLAS);
    Array<TextureAtlas.AtlasRegion> heroWalking = atlas.findRegions("Andando");
    Array<TextureAtlas.AtlasRegion> heroJump = atlas.findRegions("Saltando");
    Array<TextureAtlas.AtlasRegion> heroFall = atlas.findRegions("Cayendo");
    Array<TextureAtlas.AtlasRegion> heroIdle = atlas.findRegions("Parado");
    Animation walking = new Animation(RUNNING_FRAME_DURATION, heroWalking, Animation.PlayMode.LOOP);
    Animation jump = new Animation(RUNNING_FRAME_DURATION * 7, heroJump, Animation.PlayMode.NORMAL);
    Animation fall = new Animation(RUNNING_FRAME_DURATION * 5, heroFall, Animation.PlayMode.NORMAL);
    Animation idle = new Animation(RUNNING_FRAME_DURATION * 4, heroIdle, Animation.PlayMode.LOOP);
    Map animationHero = Collections.createMap(String.class, Animation.class);
    animationHero.put("WALKING", walking);
    animationHero.put("JUMPING", jump);
    animationHero.put("FALL", fall);
    animationHero.put("HURT", fall);
    animationHero.put("IDLE", idle);
    animationHero.put("HIT", fall);
    Body body = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(0.5f, 0.5f)).type(BodyDef.BodyType.KinematicBody).build();
    systems.add(new InputsControllerSystem(entitas.input, guiFactory)).add(new AnimationSystem(entitas)).add(new TextureRendererSystem(entitas, engine.batch));
    entitas.game.getPlayerEntity().addTextureView(null, new Bounds(0.8f, 1.2f), false, false, 1, 1, Color.WHITE).addAnimations(animationHero, walking, 0.02f).addRigidBody(body);
}
Also used : FixtureDefBuilder(ilargia.egdx.util.FixtureDefBuilder) AnimationSystem(com.indignado.games.states.game.system.AnimationSystem) Bounds(com.indignado.games.states.game.data.Bounds) Animation(com.badlogic.gdx.graphics.g2d.Animation) Map(java.util.Map) Body(com.badlogic.gdx.physics.box2d.Body) TextureRendererSystem(com.indignado.games.states.game.system.render.TextureRendererSystem) InputsControllerSystem(com.indignado.games.states.game.system.InputsControllerSystem)

Example 2 with FixtureDefBuilder

use of ilargia.egdx.util.FixtureDefBuilder 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 3 with FixtureDefBuilder

use of ilargia.egdx.util.FixtureDefBuilder 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 4 with FixtureDefBuilder

use of ilargia.egdx.util.FixtureDefBuilder in project Entitas-Java by Rubentxu.

the class GameSceneState method initialize.

@Override
public void initialize() {
    atlas = assetsManager.getTextureAtlas(SPRITE_ATLAS);
    Array<TextureAtlas.AtlasRegion> heroWalking = atlas.findRegions("Andando");
    Array<TextureAtlas.AtlasRegion> heroJump = atlas.findRegions("Saltando");
    Array<TextureAtlas.AtlasRegion> heroFall = atlas.findRegions("Cayendo");
    Array<TextureAtlas.AtlasRegion> heroIdle = atlas.findRegions("Parado");
    Animation walking = new Animation(RUNNING_FRAME_DURATION, heroWalking, Animation.PlayMode.LOOP);
    Animation jump = new Animation(RUNNING_FRAME_DURATION * 7, heroJump, Animation.PlayMode.NORMAL);
    Animation fall = new Animation(RUNNING_FRAME_DURATION * 5, heroFall, Animation.PlayMode.NORMAL);
    Animation idle = new Animation(RUNNING_FRAME_DURATION * 4, heroIdle, Animation.PlayMode.LOOP);
    Map animationHero = Collections.createMap(String.class, Animation.class);
    animationHero.put("WALKING", walking);
    animationHero.put("JUMPING", jump);
    animationHero.put("FALL", fall);
    animationHero.put("HURT", fall);
    animationHero.put("IDLE", idle);
    animationHero.put("HIT", fall);
    Body body = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(0.5f, 0.5f)).type(BodyDef.BodyType.KinematicBody).build();
    systems.add(new InputsControllerSystem(entitas.input, guiFactory)).add(new AnimationSystem(entitas)).add(new TextureRendererSystem(entitas, engine.batch));
    entitas.game.getPlayerEntity().addTextureView(null, new Bounds(0.8f, 1.2f), false, false, 1, 1, Color.WHITE).addAnimations(animationHero, walking, 0.02f).addRigidBody(body);
}
Also used : FixtureDefBuilder(ilargia.egdx.util.FixtureDefBuilder) AnimationSystem(com.ilargia.games.logicbrick.system.game.AnimationSystem) Bounds(com.ilargia.games.logicbrick.data.Bounds) Animation(com.badlogic.gdx.graphics.g2d.Animation) Map(java.util.Map) Body(com.badlogic.gdx.physics.box2d.Body) TextureRendererSystem(com.ilargia.games.logicbrick.system.render.TextureRendererSystem) InputsControllerSystem(com.ilargia.games.logicbrick.system.InputsControllerSystem)

Example 5 with FixtureDefBuilder

use of ilargia.egdx.util.FixtureDefBuilder 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)

Aggregations

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