diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index 6c6c89c..cf42e1e 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -86,7 +86,8 @@ public class GladiatorBrawler extends ApplicationAdapter { renderedObject.addSequence("Idle", sequence); renderedObject.playAnimation("Idle"); player.add(renderedObject); - player.add(new CPhysics().setSize(player1.getRegionWidth() * Global.SPRITE_SCALE, player1.getRegionHeight() * Global.SPRITE_SCALE)); + player.add(new CPhysics().setSize(player1.getRegionWidth() * Global.SPRITE_SCALE, + player1.getRegionHeight() * Global.SPRITE_SCALE).setPosition(0, 5)); engine.addEntity(player); @@ -99,7 +100,7 @@ public class GladiatorBrawler extends ApplicationAdapter { Sprite groundSprite = SpriteLoader.loadSprite(Name.GROUNDIMG, 0, 0, 256, 64); CRenderedObject renderedObject = new CRenderedObject(groundSprite); ground.add(renderedObject); - CPhysics physics = new CPhysics().setMovable(false).setGravityApplied(false) + CPhysics physics = new CPhysics().setMovable(false).setGravityApplied(false).setDynamic(false) .setSize(groundSprite.getRegionWidth() * Global.SPRITE_SCALE, groundSprite.getRegionHeight() * Global.SPRITE_SCALE); physics.position.set(new Vector2(0, -4)); @@ -109,7 +110,7 @@ public class GladiatorBrawler extends ApplicationAdapter { Entity wall0 = new Entity(); CRenderedObject wall0RenderedObject = new CRenderedObject(wallSprite); - CPhysics wall0Physics = new CPhysics().setMovable(false).setGravityApplied(false) + CPhysics wall0Physics = new CPhysics().setMovable(false).setGravityApplied(false).setDynamic(false) .setSize(wallSprite.getRegionWidth() * Global.SPRITE_SCALE, wallSprite.getRegionHeight() * Global.SPRITE_SCALE); wall0Physics.position.set(new Vector2(6, 0)); @@ -118,7 +119,7 @@ public class GladiatorBrawler extends ApplicationAdapter { Entity wall1 = new Entity(); CRenderedObject wall1RenderedObject = new CRenderedObject(wallSprite); - CPhysics wall1Physics = new CPhysics().setMovable(false).setGravityApplied(false) + CPhysics wall1Physics = new CPhysics().setMovable(false).setGravityApplied(false).setDynamic(false) .setSize(wallSprite.getRegionWidth() * Global.SPRITE_SCALE, wallSprite.getRegionHeight() * Global.SPRITE_SCALE); wall1Physics.position.set(new Vector2(-6, 0)); diff --git a/core/src/com/saltosion/gladiator/components/CPhysics.java b/core/src/com/saltosion/gladiator/components/CPhysics.java index b758cb2..f3d3824 100644 --- a/core/src/com/saltosion/gladiator/components/CPhysics.java +++ b/core/src/com/saltosion/gladiator/components/CPhysics.java @@ -43,4 +43,9 @@ public class CPhysics extends Component { return this; } + public CPhysics setPosition(float x, float y) { + this.position.set(x, y); + return this; + } + } diff --git a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java index bdecfe7..13e6139 100644 --- a/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java +++ b/core/src/com/saltosion/gladiator/systems/PhysicsSystem.java @@ -80,29 +80,30 @@ public class PhysicsSystem extends EntitySystem { return; } - if (x00 <= x11 && Math.abs(x00 - x11) < (cp0.size.x + cp1.size.x) / 4) { + if (x00 <= x11 && Math.abs(x00 - x11) < (cp0.size.x + cp1.size.x) / 16) { // cp0's left side is colliding with cp1's right side if (cp0.velocity.x < 0) { // cp0 is going left, stop cp0.velocity.x = 0; } } - if (x01 > x10 && Math.abs(x01 - x10) < (cp0.size.x + cp1.size.x) / 4) { + if (x01 > x10 && Math.abs(x01 - x10) < (cp0.size.x + cp1.size.x) / 16) { // cp0's right side is colliding with cp1's left side if (cp0.velocity.x > 0) { // cp0 is going right, stop cp0.velocity.x = 0; } } - if (y00 <= y11 && Math.abs(y00 - y11) < (cp0.size.y + cp1.size.y) / 4) { + if (y00 <= y11 && Math.abs(y00 - y11) < (cp0.size.y + cp1.size.y) / 16) { // cp0's bottom side is colliding with cp1's top side if (cp0.velocity.y < 0) { // cp0 is going down, stop cp0.velocity.y = 0; } cp0.grounded = true; + //cp0.position.y -= Math.abs(y00 - y11); } - if (y01 > y10 && Math.abs(y01 - y10) < (cp0.size.y + cp1.size.y) / 4) { + if (y01 > y10 && Math.abs(y01 - y10) < (cp0.size.y + cp1.size.y) / 16) { // cp0's top side is colliding with cp1's bottom side if (cp0.velocity.y > 0) { // cp0 is going up, stop diff --git a/core/src/com/saltosion/gladiator/util/AppUtil.java b/core/src/com/saltosion/gladiator/util/AppUtil.java index c74c491..1bd25a3 100644 --- a/core/src/com/saltosion/gladiator/util/AppUtil.java +++ b/core/src/com/saltosion/gladiator/util/AppUtil.java @@ -1,13 +1,13 @@ - package com.saltosion.gladiator.util; +package com.saltosion.gladiator.util; import com.badlogic.ashley.core.Entity; import com.badlogic.gdx.math.Vector2; public class AppUtil { - - public static Entity player; - - public static final int VPHEIGHT_CONST = 14; - - public static final Vector2 JUMP_FORCE = new Vector2(0, 12000); + + public static Entity player; + + public static final int VPHEIGHT_CONST = 24; + + public static final Vector2 JUMP_FORCE = new Vector2(0, 12000); }