Fixed entity trigger detection

This commit is contained in:
Mike Schwörer 2017-05-17 21:02:23 +02:00
parent 5ad0e5902a
commit 5f194e1bb8
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
4 changed files with 32 additions and 21 deletions

View File

@ -3521,9 +3521,9 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="23"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -4021,9 +4021,9 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -4523,7 +4523,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -5023,7 +5023,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -5523,7 +5523,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -6023,7 +6023,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -6523,7 +6523,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -7023,7 +7023,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -7523,7 +7523,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -8023,7 +8023,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -8521,9 +8521,9 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -9021,9 +9021,9 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="23"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -14026,7 +14026,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="17"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
@ -19026,7 +19026,7 @@
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="16"/>
<tile gid="0"/>
<tile gid="0"/>
<tile gid="0"/>

View File

@ -100,6 +100,11 @@ public class CRGameRenderer extends AbstractGameRenderer {
}
}
//int px = (int)((gameworld.player.bounds.x + gameworld.player.bounds.width / 2f) / FloorTileEntity.FLOORTILE_WIDTH);
//int py = (int)((gameworld.player.bounds.y + gameworld.player.bounds.height / 2f) / FloorTileEntity.FLOORTILE_HEIGHT);
//shapeRenderer.setColor(0, 0, 1, 1f);
//shapeRenderer.rect(px * FloorTileEntity.FLOORTILE_WIDTH, py * FloorTileEntity.FLOORTILE_HEIGHT, FloorTileEntity.FLOORTILE_WIDTH, FloorTileEntity.FLOORTILE_HEIGHT);
shapeRenderer.end();
}
@ -150,7 +155,7 @@ public class CRGameRenderer extends AbstractGameRenderer {
renderDebug("Level Progress: " + ((StaticMapProvider)gameworld.mapprovider).mapPlayerPos + "/" + ((StaticMapProvider)gameworld.mapprovider).mapMaxWidth);
renderDebug("Player(tile): [" + (int)(gameworld.player.bounds.x / FloorTileEntity.FLOORTILE_WIDTH) + "|" + (int)(gameworld.player.bounds.y / FloorTileEntity.FLOORTILE_WIDTH) + "]");
renderDebug("Player(trigger): " + gameworld.mapprovider.getTrigger((int)(gameworld.player.bounds.x / FloorTileEntity.FLOORTILE_WIDTH), (int)(gameworld.player.bounds.y / FloorTileEntity.FLOORTILE_WIDTH)));
renderDebug("Player(trigger): " + gameworld.player.getTrigger());
renderDebug("Player(velo): [" + gameworld.player.velocity.x + " | " + gameworld.player.velocity.y + "]");
endDebug();

View File

@ -5,6 +5,8 @@ import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import de.samdev.colorrunner.game.world.CRGameWorld;
import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity;
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
public abstract class CRGameEntity {
@ -43,4 +45,8 @@ public abstract class CRGameEntity {
public abstract Texture getTexture();
public abstract boolean canCollide(boolean actualCollision, CRGameEntity collider);
public TriggerType getTrigger() {
return world.mapprovider.getTrigger((int)((bounds.x + bounds.width/2f) / FloorTileEntity.FLOORTILE_WIDTH), (int)((bounds.y + bounds.height/2f) / FloorTileEntity.FLOORTILE_HEIGHT));
}
}

View File

@ -41,7 +41,7 @@ public class PlayerEntity extends MovingEntity {
updateRotation(delta);
TriggerType trigger = world.mapprovider.getTrigger((int)((bounds.x + bounds.width/2f) / FloorTileEntity.FLOORTILE_WIDTH), (int)((bounds.y + bounds.height/2f) / FloorTileEntity.FLOORTILE_HEIGHT));
TriggerType trigger = getTrigger();
switch (trigger){
case RUNTOP:
if (controller.getControllerType() != ControllingType.RUNTOP) controller = new RunTopPlayerController(this);