Hitbox is now more appropriate in size, to be changed later

This commit is contained in:
Allexit 2015-05-10 22:05:46 +03:00
parent 6e1387662d
commit 4f06d6af74
5 changed files with 8 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -11,7 +11,7 @@ public class CCombat extends Component {
public int health = 0;
private int maxHealth = 0;
private int damage = 0;
private Vector2 swingsize = new Vector2(4, 4);
private Vector2 swingsize = new Vector2(4, 3);
private Vector2 swinging = new Vector2();
private float swingCd = 0;

View File

@ -57,13 +57,13 @@ public class CombatSystem extends EntitySystem {
Vector2 pos = obj.getPosition().cpy();
if (combat.getSwingDirection() == Direction.LEFT) {
pos.add(-2, 0);
pos.add(-combat.getSwingSize().x/2, 0);
} else if (combat.getSwingDirection() == Direction.RIGHT) {
pos.add(2, 0);
pos.add(combat.getSwingSize().x/2, 0);
} else if (combat.getSwingDirection() == Direction.UP) {
pos.add(0, 2);
pos.add(0, combat.getSwingSize().y);
} else if (combat.getSwingDirection() == Direction.DOWN) {
pos.add(0, -2);
pos.add(0, -combat.getSwingSize().y/3*2);
}
createSwingHitbox(e, pos);
@ -75,7 +75,7 @@ public class CombatSystem extends EntitySystem {
public void createSwingHitbox(Entity source, Vector2 position) {
Entity e = new Entity();
CCombat combat = cm.get(source);
Sprite s = SpriteLoader.loadSprite(Name.WALLIMG);
Sprite s = SpriteLoader.loadSprite(Name.SWINGHITBOXIMG);
e.add(new CRenderedObject(s));
e.add(new CPhysics().setGhost(true).setGravityApplied(false).setMovable(false)
.setSize(combat.getSwingSize()));

View File

@ -8,6 +8,7 @@ public class Name {
public static final String PLAYERIMG = "PLAYERIMG";
public static final String GROUNDIMG = "GROUNDIMG";
public static final String WALLIMG = "WALLIMG";
public static final String SWINGHITBOXIMG = "SWINGHITBOXIMG";
public static final String MOVE_LEFT = "MOVE_LEFT";
public static final String MOVE_RIGHT = "MOVE_RIGHT";

View File

@ -16,6 +16,7 @@ public class SpriteLoader {
loadTexture(Name.PLAYERIMG, "sprites/player/player.png");
loadTexture(Name.GROUNDIMG, "sprites/ground.png");
loadTexture(Name.WALLIMG, "sprites/wall.png");
loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png");
}
/**