renamed listeners package, added test dummy to kill
This commit is contained in:
parent
4f06d6af74
commit
c758862906
@ -66,6 +66,7 @@ public class GladiatorBrawler extends ApplicationAdapter {
|
|||||||
|
|
||||||
// Initialize stuff in the world
|
// Initialize stuff in the world
|
||||||
initializePlayer();
|
initializePlayer();
|
||||||
|
initializeTestDummy();
|
||||||
initializeLevel();
|
initializeLevel();
|
||||||
|
|
||||||
// Initialize input
|
// Initialize input
|
||||||
@ -95,6 +96,20 @@ public class GladiatorBrawler extends ApplicationAdapter {
|
|||||||
AppUtil.player = player;
|
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() {
|
public void initializeLevel() {
|
||||||
Entity ground = new Entity();
|
Entity ground = new Entity();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package com.saltosion.gladiator.components;
|
|||||||
|
|
||||||
import com.badlogic.ashley.core.Component;
|
import com.badlogic.ashley.core.Component;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.saltosion.gladiator.collisionlisteners.CollisionListener;
|
import com.saltosion.gladiator.listeners.CollisionListener;
|
||||||
|
|
||||||
public class CPhysics extends Component {
|
public class CPhysics extends Component {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.saltosion.gladiator.collisionlisteners;
|
package com.saltosion.gladiator.listeners;
|
||||||
|
|
||||||
import com.badlogic.ashley.core.Entity;
|
import com.badlogic.ashley.core.Entity;
|
||||||
import com.saltosion.gladiator.util.Direction;
|
import com.saltosion.gladiator.util.Direction;
|
@ -1,10 +1,11 @@
|
|||||||
package com.saltosion.gladiator.collisionlisteners;
|
package com.saltosion.gladiator.listeners;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.badlogic.ashley.core.ComponentMapper;
|
import com.badlogic.ashley.core.ComponentMapper;
|
||||||
import com.badlogic.ashley.core.Entity;
|
import com.badlogic.ashley.core.Entity;
|
||||||
import com.saltosion.gladiator.components.CCombat;
|
import com.saltosion.gladiator.components.CCombat;
|
||||||
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
import com.saltosion.gladiator.util.Direction;
|
import com.saltosion.gladiator.util.Direction;
|
||||||
|
|
||||||
public class SwingHitboxListener implements CollisionListener {
|
public class SwingHitboxListener implements CollisionListener {
|
||||||
@ -31,7 +32,11 @@ public class SwingHitboxListener implements CollisionListener {
|
|||||||
}
|
}
|
||||||
int damage = cm.get(source).getDamage();
|
int damage = cm.get(source).getDamage();
|
||||||
otherCombat.health -= damage;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -8,11 +8,11 @@ import com.badlogic.ashley.core.Family;
|
|||||||
import com.badlogic.ashley.utils.ImmutableArray;
|
import com.badlogic.ashley.utils.ImmutableArray;
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.saltosion.gladiator.collisionlisteners.SwingHitboxListener;
|
|
||||||
import com.saltosion.gladiator.components.CCombat;
|
import com.saltosion.gladiator.components.CCombat;
|
||||||
import com.saltosion.gladiator.components.CDestructive;
|
import com.saltosion.gladiator.components.CDestructive;
|
||||||
import com.saltosion.gladiator.components.CPhysics;
|
import com.saltosion.gladiator.components.CPhysics;
|
||||||
import com.saltosion.gladiator.components.CRenderedObject;
|
import com.saltosion.gladiator.components.CRenderedObject;
|
||||||
|
import com.saltosion.gladiator.listeners.SwingHitboxListener;
|
||||||
import com.saltosion.gladiator.util.AppUtil;
|
import com.saltosion.gladiator.util.AppUtil;
|
||||||
import com.saltosion.gladiator.util.Direction;
|
import com.saltosion.gladiator.util.Direction;
|
||||||
import com.saltosion.gladiator.util.Name;
|
import com.saltosion.gladiator.util.Name;
|
||||||
|
Loading…
Reference in New Issue
Block a user