Hitbox is now more appropriate in size, to be changed later
This commit is contained in:
parent
6e1387662d
commit
4f06d6af74
BIN
core/assets/sprites/swinghitbox.png
Normal file
BIN
core/assets/sprites/swinghitbox.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
@ -11,7 +11,7 @@ public class CCombat extends Component {
|
|||||||
public int health = 0;
|
public int health = 0;
|
||||||
private int maxHealth = 0;
|
private int maxHealth = 0;
|
||||||
private int damage = 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 Vector2 swinging = new Vector2();
|
||||||
private float swingCd = 0;
|
private float swingCd = 0;
|
||||||
|
@ -57,13 +57,13 @@ public class CombatSystem extends EntitySystem {
|
|||||||
Vector2 pos = obj.getPosition().cpy();
|
Vector2 pos = obj.getPosition().cpy();
|
||||||
|
|
||||||
if (combat.getSwingDirection() == Direction.LEFT) {
|
if (combat.getSwingDirection() == Direction.LEFT) {
|
||||||
pos.add(-2, 0);
|
pos.add(-combat.getSwingSize().x/2, 0);
|
||||||
} else if (combat.getSwingDirection() == Direction.RIGHT) {
|
} else if (combat.getSwingDirection() == Direction.RIGHT) {
|
||||||
pos.add(2, 0);
|
pos.add(combat.getSwingSize().x/2, 0);
|
||||||
} else if (combat.getSwingDirection() == Direction.UP) {
|
} else if (combat.getSwingDirection() == Direction.UP) {
|
||||||
pos.add(0, 2);
|
pos.add(0, combat.getSwingSize().y);
|
||||||
} else if (combat.getSwingDirection() == Direction.DOWN) {
|
} else if (combat.getSwingDirection() == Direction.DOWN) {
|
||||||
pos.add(0, -2);
|
pos.add(0, -combat.getSwingSize().y/3*2);
|
||||||
}
|
}
|
||||||
createSwingHitbox(e, pos);
|
createSwingHitbox(e, pos);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class CombatSystem extends EntitySystem {
|
|||||||
public void createSwingHitbox(Entity source, Vector2 position) {
|
public void createSwingHitbox(Entity source, Vector2 position) {
|
||||||
Entity e = new Entity();
|
Entity e = new Entity();
|
||||||
CCombat combat = cm.get(source);
|
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 CRenderedObject(s));
|
||||||
e.add(new CPhysics().setGhost(true).setGravityApplied(false).setMovable(false)
|
e.add(new CPhysics().setGhost(true).setGravityApplied(false).setMovable(false)
|
||||||
.setSize(combat.getSwingSize()));
|
.setSize(combat.getSwingSize()));
|
||||||
|
@ -8,6 +8,7 @@ public class Name {
|
|||||||
public static final String PLAYERIMG = "PLAYERIMG";
|
public static final String PLAYERIMG = "PLAYERIMG";
|
||||||
public static final String GROUNDIMG = "GROUNDIMG";
|
public static final String GROUNDIMG = "GROUNDIMG";
|
||||||
public static final String WALLIMG = "WALLIMG";
|
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_LEFT = "MOVE_LEFT";
|
||||||
public static final String MOVE_RIGHT = "MOVE_RIGHT";
|
public static final String MOVE_RIGHT = "MOVE_RIGHT";
|
||||||
|
@ -16,6 +16,7 @@ public class SpriteLoader {
|
|||||||
loadTexture(Name.PLAYERIMG, "sprites/player/player.png");
|
loadTexture(Name.PLAYERIMG, "sprites/player/player.png");
|
||||||
loadTexture(Name.GROUNDIMG, "sprites/ground.png");
|
loadTexture(Name.GROUNDIMG, "sprites/ground.png");
|
||||||
loadTexture(Name.WALLIMG, "sprites/wall.png");
|
loadTexture(Name.WALLIMG, "sprites/wall.png");
|
||||||
|
loadTexture(Name.SWINGHITBOXIMG, "sprites/swinghitbox.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user