minor work on entities and added speed control to polyjet entity

This commit is contained in:
Harrison Deng 2017-06-02 09:28:53 -05:00
parent f5352b8e22
commit 1832f32b6a
4 changed files with 34 additions and 6 deletions

View File

@ -23,6 +23,8 @@ public class KeyMap {
public static final String SECONDTHIRDTELEPORT = "secondThirdTP";
public static final String THIRDTHIRDTELEPORT = "thirdThirdTP";
public static final String ACCELERATE = "accelerate";
/**
* forward binding.
*/
@ -56,6 +58,8 @@ public class KeyMap {
*/
public static int thirdThirdTeleport;
public static int accelerate;
public KeyMap(Polyjet core) {
keyTextures = core.getAssetManager().get("keyboard.atlas", TextureAtlas.class);
@ -108,6 +112,8 @@ public class KeyMap {
firstThirdTeleport = keyBindPrefs.getInteger(KeyMap.FIRSTTHIRDTELEPORT, Keys.Q);
secondThirdTeleport = keyBindPrefs.getInteger(KeyMap.SECONDTHIRDTELEPORT, Keys.W);
thirdThirdTeleport = keyBindPrefs.getInteger(KeyMap.THIRDTHIRDTELEPORT, Keys.E);
accelerate = keyBindPrefs.getInteger(KeyMap.ACCELERATE, Keys.SHIFT_LEFT);
}
/**
@ -135,6 +141,8 @@ public class KeyMap {
return KeyMap.secondThirdTeleport;
} else if (control == KeyMap.THIRDTHIRDTELEPORT) {
return KeyMap.thirdThirdTeleport;
} else if (control == KeyMap.ACCELERATE) {
return KeyMap.accelerate;
} else {
return -1;
}

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
@ -20,10 +21,12 @@ public class PolyJetEntity extends Actor implements Entity {
private ParticleEffect teleportCloak;
private Rectangle hitbox;
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting;
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting, accelerate;
private float speed, accel;
private float rate;
public PolyJetEntity(AssetManager assets, float rate, String jet) {
this.rate = rate;
public PolyJetEntity(AssetManager assets, float speed, float accel, String jet) {
this.speed = speed;
this.accel = accel;
setSize(1.5f, 1.5f);
setPosition(Polyjet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
@ -47,6 +50,12 @@ public class PolyJetEntity extends Actor implements Entity {
//Movement!
if (accelerate) {
rate = speed + accel;
} else {
rate = speed;
}
if (moveLeft && !moveRight) {
moveBy(-(rate*delta), 0);
}
@ -60,7 +69,7 @@ public class PolyJetEntity extends Actor implements Entity {
if (moveDown && !moveUp) {
moveBy(0, -rate*delta);
}
super.act(delta);
}

View File

@ -56,8 +56,10 @@ public class Pellet extends Actor implements Entity, Poolable {
@Override
public void collided(Entity entity) {
if (entity.getEntityType() == Entities.LASER) {
switch (entity.getEntityType()) {
default:
dead = true;
break;
}
}

View File

@ -31,7 +31,7 @@ public class GamePlayArea extends Stage {
public GamePlayArea(AssetManager assetManager) {
super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT));
polyjet = new PolyJetEntity(assetManager, 48f, "standard");
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard");
shapes = new ShapeRenderer();
shapes.setProjectionMatrix(getCamera().combined);
@ -92,6 +92,10 @@ public class GamePlayArea extends Stage {
if (keycode == KeyMap.down) {
polyjet.moveDown = true;
}
if (keycode == KeyMap.accelerate) {
polyjet.accelerate = true;
}
return false;
}
@ -109,6 +113,11 @@ public class GamePlayArea extends Stage {
if (keycode == KeyMap.down) {
polyjet.moveDown = false;
}
if (keycode == KeyMap.accelerate) {
polyjet.accelerate = false;
}
if (keycode == KeyMap.shoot) {
Laser laser = (Laser) entityController.retrieveEntity(Entities.LASER);
laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2f, polyjet.getY() + polyjet.getHeight()+0.25f, 30f);