From 4f06d6af740de471faec235e76351720476923ed Mon Sep 17 00:00:00 2001 From: Allexit Date: Sun, 10 May 2015 22:05:46 +0300 Subject: [PATCH] Hitbox is now more appropriate in size, to be changed later --- core/assets/sprites/swinghitbox.png | Bin 0 -> 2374 bytes .../saltosion/gladiator/components/CCombat.java | 2 +- .../gladiator/systems/CombatSystem.java | 10 +++++----- core/src/com/saltosion/gladiator/util/Name.java | 1 + .../saltosion/gladiator/util/SpriteLoader.java | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 core/assets/sprites/swinghitbox.png diff --git a/core/assets/sprites/swinghitbox.png b/core/assets/sprites/swinghitbox.png new file mode 100644 index 0000000000000000000000000000000000000000..59e08fd6e24628d0cca26df2ef2c8b0d647aab11 GIT binary patch literal 2374 zcmV-M3Ay%(P)?VkVu03B&m zSad^gZEa<4bN~PV002XBWnpw>WFU8GbZ8()Nlj2>E@cM*00^o{L_t(&-tAd?P?Xmd z|K0oTvWo=PDY}h-ilU2lK%8iXX0kRw)PzxNq@p2{#7WeV`kTOBhsRny5fDn65l zPGW2&Mp|v~NhE@%){0Y5G9o^rJS~bYBD>4(ckk&R%eLzlDH>A^?wR>!zB%{Yz4!jk zx#yhyeGH&PJjTNDn2R3(KLCCJ`~W;uAwm%miXJHdmMs%QYHMk^%|>}H7aeMCr5zV8 z&@bP4N5piu2w=W_z$c$b^DD2gWt=nC;RJ@HZhZwNOki(v&e+wfbaK%mF(WKYeK8?H zq<;FTeEZrpD)06=phpjc1Hfyq$=_Kl%Eg8TjkCB|vA+B=KVmepEN|OBebfM#iw+4v zhfO9m(4)6nX)_UutXBHaqcfS*Kq2U`%S8wK^icyk%K;u;WTdJ)f1a}2+Ni+cpxtF< zG=njDM`TW&D#B`OX@%2C`y3A1U0F$4k&&vdtGVUB0I=Ip4*<)Tv+-uLFmyJ#p+V!c zT2aY4V;LDd8URL)RD*+qF%STPgAo-MCxQTA=1gwloH45vl?@FVXIH#aQlk87&>)r^ z5WsrqbSxw;j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4k(!VoQVR;C#pxuQ(a45>{yG2Ii4#i8 zwrykqfaGL0RjU!zp#)t0>H3gZkvn@{`bmC`b%&y>$h_!8=aTOMh6G8 zzGY?jV|KQ3=ANp+-Lm?FE^BMo$}`?RShr4=zy3N$U?BPcKu{1O0Kj6Qhp4+$c%!dMi)9I$8ROm*&ZnS>}81$vBfq4P3QK4xcp1 zO=e!Ye zfD(;H*Vx8Jd7ADbjg9gjp`orZNlEHNheKM4h;nnqV$V9ec8TRgM0UHpX*R1bb#$ih zECOcDlIv?~sHClpT0GamR}vG&%Jb)GpVLV#E*ClK>gcQK)8)JqCzKYz{b3{~Ml3vb zOm1!`X`QM{ZOzSe>DV#(;n1OCQB#vf{pch93!RP`u3x8$>C^eY6J}Z(if-JXbM04Q so}Uo${}=EB;0M4DfFA%q0C&j00JJ;0!<1@wsQ>@~07*qoM6N<$f^E!g!~g&Q literal 0 HcmV?d00001 diff --git a/core/src/com/saltosion/gladiator/components/CCombat.java b/core/src/com/saltosion/gladiator/components/CCombat.java index 3288a60..0274eac 100644 --- a/core/src/com/saltosion/gladiator/components/CCombat.java +++ b/core/src/com/saltosion/gladiator/components/CCombat.java @@ -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; diff --git a/core/src/com/saltosion/gladiator/systems/CombatSystem.java b/core/src/com/saltosion/gladiator/systems/CombatSystem.java index 6dcfef2..f9052a6 100644 --- a/core/src/com/saltosion/gladiator/systems/CombatSystem.java +++ b/core/src/com/saltosion/gladiator/systems/CombatSystem.java @@ -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())); diff --git a/core/src/com/saltosion/gladiator/util/Name.java b/core/src/com/saltosion/gladiator/util/Name.java index 5921a05..4643e4c 100644 --- a/core/src/com/saltosion/gladiator/util/Name.java +++ b/core/src/com/saltosion/gladiator/util/Name.java @@ -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"; diff --git a/core/src/com/saltosion/gladiator/util/SpriteLoader.java b/core/src/com/saltosion/gladiator/util/SpriteLoader.java index c0f89c3..a4efa07 100644 --- a/core/src/com/saltosion/gladiator/util/SpriteLoader.java +++ b/core/src/com/saltosion/gladiator/util/SpriteLoader.java @@ -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"); } /**