renamed listeners package, added test dummy to kill

This commit is contained in:
Allexit 2015-05-10 22:26:12 +03:00
parent 4f06d6af74
commit c758862906
5 changed files with 25 additions and 5 deletions

View File

@ -66,6 +66,7 @@ public class GladiatorBrawler extends ApplicationAdapter {
// Initialize stuff in the world
initializePlayer();
initializeTestDummy();
initializeLevel();
// Initialize input
@ -94,6 +95,20 @@ public class GladiatorBrawler extends ApplicationAdapter {
AppUtil.player = player;
}
public void initializeTestDummy() {
Entity dummy = new Entity();
CRenderedObject renderedObject = new CRenderedObject();
Sprite player1 = SpriteLoader.loadSprite(Name.PLAYERIMG, 0, 0, 64, 64);
Sprite player2 = SpriteLoader.loadSprite(Name.PLAYERIMG, 1, 0, 64, 64);
SpriteSequence sequence = new SpriteSequence(1).addSprite(player1).addSprite(player2);
renderedObject.addSequence("Idle", sequence);
renderedObject.playAnimation("Idle");
dummy.add(renderedObject);
dummy.add(new CPhysics().setSize(2, 4).setPosition(-6, 5));
dummy.add(new CCombat().setBaseDamage(100).setHealth(1000).setSwingCD(.5f));
engine.addEntity(dummy);
}
public void initializeLevel() {
Entity ground = new Entity();

View File

@ -2,7 +2,7 @@ package com.saltosion.gladiator.components;
import com.badlogic.ashley.core.Component;
import com.badlogic.gdx.math.Vector2;
import com.saltosion.gladiator.collisionlisteners.CollisionListener;
import com.saltosion.gladiator.listeners.CollisionListener;
public class CPhysics extends Component {

View File

@ -1,4 +1,4 @@
package com.saltosion.gladiator.collisionlisteners;
package com.saltosion.gladiator.listeners;
import com.badlogic.ashley.core.Entity;
import com.saltosion.gladiator.util.Direction;

View File

@ -1,10 +1,11 @@
package com.saltosion.gladiator.collisionlisteners;
package com.saltosion.gladiator.listeners;
import java.util.ArrayList;
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.saltosion.gladiator.components.CCombat;
import com.saltosion.gladiator.util.AppUtil;
import com.saltosion.gladiator.util.Direction;
public class SwingHitboxListener implements CollisionListener {
@ -31,7 +32,11 @@ public class SwingHitboxListener implements CollisionListener {
}
int damage = cm.get(source).getDamage();
otherCombat.health -= damage;
System.out.println("Entity was hit for " + damage + " damage!");
System.out.println(String.format("Entity was hit for %d damage, it now has only %d health left!",
damage, otherCombat.health));
if (otherCombat.health <= 0) {
AppUtil.engine.removeEntity(other);
}
}
}

View File

@ -8,11 +8,11 @@ import com.badlogic.ashley.core.Family;
import com.badlogic.ashley.utils.ImmutableArray;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.saltosion.gladiator.collisionlisteners.SwingHitboxListener;
import com.saltosion.gladiator.components.CCombat;
import com.saltosion.gladiator.components.CDestructive;
import com.saltosion.gladiator.components.CPhysics;
import com.saltosion.gladiator.components.CRenderedObject;
import com.saltosion.gladiator.listeners.SwingHitboxListener;
import com.saltosion.gladiator.util.AppUtil;
import com.saltosion.gladiator.util.Direction;
import com.saltosion.gladiator.util.Name;