Finished implementing stasis (only sprites need to be improved)
Added forces to player in order for stasis to work
This commit is contained in:
parent
b8e3729bb1
commit
4e758353b8
@ -0,0 +1,18 @@
|
|||||||
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
|
import de.frajul.endlessroll.data.Vector;
|
||||||
|
import de.frajul.endlessroll.entities.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Julian on 03.11.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public abstract class PlayerInfluenceTool extends Tool {
|
||||||
|
|
||||||
|
public PlayerInfluenceTool(ToolType type, Vector position, float width, float height, boolean updateBounds, boolean placedByRightEdge) {
|
||||||
|
super(type, position, width, height, updateBounds, placedByRightEdge);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void influencePlayerValues(Player player);
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,6 @@ package de.frajul.endlessroll.entities.tools;
|
|||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.DestroyEffect;
|
import de.frajul.endlessroll.entities.DestroyEffect;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
||||||
@ -12,12 +11,18 @@ import de.frajul.endlessroll.main.game.Timer;
|
|||||||
/**
|
/**
|
||||||
* Created by Julian on 11.02.2016.
|
* Created by Julian on 11.02.2016.
|
||||||
*/
|
*/
|
||||||
public class Stasis extends Tool {
|
public class Stasis extends PlayerInfluenceTool {
|
||||||
|
|
||||||
private ParticleSource particleSource;
|
private ParticleSource particleSource;
|
||||||
|
private boolean firstCollision = true;
|
||||||
|
private final static float Y_SLOW_FACTOR = .2f;
|
||||||
|
private final static float X_SLOW_FACTOR = .8f;
|
||||||
|
|
||||||
public Stasis(Vector position, ParticleSystem particleSystem) {
|
public Stasis(Vector position, ParticleSystem particleSystem) {
|
||||||
super(ToolType.STASIS, position, .7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, .7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, false, false);
|
super(ToolType.STASIS, position,
|
||||||
|
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100,
|
||||||
|
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, false,
|
||||||
|
false);
|
||||||
animation.setLooping(true);
|
animation.setLooping(true);
|
||||||
animation.setRequiredDelta(300);
|
animation.setRequiredDelta(300);
|
||||||
animation.setIndexSequence(new int[]{1, 1, 2, 3, 2, 4, 4, 3, 2, 2, 3, 3});
|
animation.setIndexSequence(new int[]{1, 1, 2, 3, 2, 4, 4, 3, 2, 2, 3, 3});
|
||||||
@ -34,7 +39,7 @@ public class Stasis extends Tool {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
player.getMovement().setY(0);
|
player.addInfluenceTool(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,4 +51,15 @@ public class Stasis extends Tool {
|
|||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void influencePlayerValues(Player player) {
|
||||||
|
player.manipulateAllForces(Y_SLOW_FACTOR);
|
||||||
|
player.getMovement().setX(player.getMovement().getX() * .8f);
|
||||||
|
if (firstCollision) {
|
||||||
|
player.getMovement().y *= Y_SLOW_FACTOR;
|
||||||
|
firstCollision = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user