Spieler geht nach oben und unten, fällt aber oben noch durch die Boxen
This commit is contained in:
parent
0052a50521
commit
b1eeed1119
File diff suppressed because it is too large
Load Diff
|
@ -13,6 +13,7 @@ import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEnt
|
||||||
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
|
import de.samdev.colorrunner.game.world.map.provider.TriggerType;
|
||||||
import de.samdev.colorrunner.screens.menu.MainMenu;
|
import de.samdev.colorrunner.screens.menu.MainMenu;
|
||||||
|
|
||||||
|
import static de.samdev.colorrunner.game.world.map.provider.TriggerType.RUNBOTTOM;
|
||||||
import static de.samdev.colorrunner.game.world.map.provider.TriggerType.RUNTOP;
|
import static de.samdev.colorrunner.game.world.map.provider.TriggerType.RUNTOP;
|
||||||
|
|
||||||
public class PlayerEntity extends GravityEntity {
|
public class PlayerEntity extends GravityEntity {
|
||||||
|
@ -43,8 +44,12 @@ public class PlayerEntity extends GravityEntity {
|
||||||
if (velocity.x < PLAYER_TERMINAL_SPEED)
|
if (velocity.x < PLAYER_TERMINAL_SPEED)
|
||||||
velocity.x += PLAYER_SPEED_FORCE * delta;
|
velocity.x += PLAYER_SPEED_FORCE * delta;
|
||||||
|
|
||||||
if (doFly)
|
if (doFly) {
|
||||||
velocity.y += PLAYER_FLY_FORCE * delta;
|
if ( getType == GetTriggerType.RUNBOTTOM)
|
||||||
|
velocity.y += PLAYER_FLY_FORCE * delta;
|
||||||
|
else if(getType == GetTriggerType.RUNTOP)
|
||||||
|
velocity.y += -PLAYER_FLY_FORCE * delta;
|
||||||
|
}
|
||||||
doFly = false;
|
doFly = false;
|
||||||
|
|
||||||
updateRotation(delta);
|
updateRotation(delta);
|
||||||
|
@ -68,14 +73,22 @@ public class PlayerEntity extends GravityEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRotation(float delta) {
|
private void updateRotation(float delta) {
|
||||||
if (!isTouching_BOTTOM() || visualRotation % 90 != 0) {
|
if (((!isTouching_BOTTOM() && getType == GetTriggerType.RUNBOTTOM)||(!isTouching_TOP() && getType == GetTriggerType.RUNTOP) )|| visualRotation % 90 != 0) {
|
||||||
if (! isTouching_BOTTOM()) {
|
if (! isTouching_BOTTOM() && getType == GetTriggerType.RUNBOTTOM) {
|
||||||
visualRotation = visualRotation + PLAYER_ROTATION_SPEED * delta;
|
visualRotation = visualRotation + PLAYER_ROTATION_SPEED * delta;
|
||||||
visualRotation = (visualRotation + 720f) % 360f;
|
visualRotation = (visualRotation + 720f) % 360f;
|
||||||
|
|
||||||
float p = (float) ((Math.max(Math.abs(Math.cos(Math.toRadians(visualRotation + 45))), Math.abs(Math.sin(Math.toRadians(visualRotation + 45)))) * Math.sqrt(PLAYER_WIDTH * PLAYER_WIDTH + PLAYER_HEIGHT * PLAYER_HEIGHT)));
|
float p = (float) ((Math.max(Math.abs(Math.cos(Math.toRadians(visualRotation + 45))), Math.abs(Math.sin(Math.toRadians(visualRotation + 45)))) * Math.sqrt(PLAYER_WIDTH * PLAYER_WIDTH + PLAYER_HEIGHT * PLAYER_HEIGHT)));
|
||||||
updateHitBox(p, p);
|
updateHitBox(p, p);
|
||||||
} else {
|
}
|
||||||
|
else if (!isTouching_TOP() && getType == GetTriggerType.RUNTOP){
|
||||||
|
visualRotation = visualRotation + PLAYER_ROTATION_SPEED * delta;
|
||||||
|
visualRotation = (visualRotation + 720f) % 360f;
|
||||||
|
|
||||||
|
float p = (float) ((Math.max(Math.abs(Math.cos(Math.toRadians(visualRotation + 45))), Math.abs(Math.sin(Math.toRadians(visualRotation + 45)))) * Math.sqrt(PLAYER_WIDTH * PLAYER_WIDTH + PLAYER_HEIGHT * PLAYER_HEIGHT)));
|
||||||
|
updateHitBox(p, p);
|
||||||
|
}
|
||||||
|
else {
|
||||||
visualRotation = (visualRotation + 720f) % 90f;
|
visualRotation = (visualRotation + 720f) % 90f;
|
||||||
|
|
||||||
if (visualRotation < 45)
|
if (visualRotation < 45)
|
||||||
|
@ -95,8 +108,10 @@ public class PlayerEntity extends GravityEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void jump() {
|
public void jump() {
|
||||||
if (isTouching_BOTTOM())
|
if (isTouching_BOTTOM() && getType == GetTriggerType.RUNBOTTOM)
|
||||||
velocity.y = PLAYER_JUMP_FORCE;
|
velocity.y = PLAYER_JUMP_FORCE;
|
||||||
|
else if(isTouching_TOP() && getType == GetTriggerType.RUNTOP)
|
||||||
|
velocity.y = -PLAYER_JUMP_FORCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchPhase(SwipeDirection sd) {
|
public void switchPhase(SwipeDirection sd) {
|
||||||
|
@ -113,7 +128,9 @@ public class PlayerEntity extends GravityEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fly() {
|
public void fly() {
|
||||||
if (!isTouching_BOTTOM())
|
if (!isTouching_BOTTOM() && getType == GetTriggerType.RUNBOTTOM)
|
||||||
|
doFly = true;
|
||||||
|
else if(isTouching_TOP() && getType == GetTriggerType.RUNTOP)
|
||||||
doFly = true;
|
doFly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue