added border to show status effects, preparing for better score system

This commit is contained in:
Harrison Deng 2017-08-08 02:26:34 -05:00
parent 5f8b8f95fc
commit 29c30290fb
9 changed files with 84 additions and 43 deletions

View File

@ -319,3 +319,10 @@ large-pane
orig: 9, 27 orig: 9, 27
offset: 0, 0 offset: 0, 0
index: -1 index: -1
gradient-bar
rotate: false
xy: 26, 7
size: 3, 1
orig: 3, 1
offset: 0, 0
index: -1

View File

@ -9,26 +9,24 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import zero1hd.rhythmbullet.RhythmBullet; import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.entity.Entity; import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.ui.builders.HealthBar;
public class PolyJetEntity extends Entity { public class PolyjetEntity extends Entity {
public float health; public float health;
private ParticleEffect thrust; private ParticleEffect thrust;
private Texture polyjet; private Texture polyjet;
private ParticleEffect teleportCloak; private ParticleEffect teleportCloak;
private HealthBar hpBar;
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting, accelerate; public boolean moveLeft, moveRight, moveUp, moveDown, teleporting, accelerate;
private float speed, accel; private float speed, accel;
private float rate; private float rate;
public PolyJetEntity(AssetManager assets, float speed, float accel, String jet, HealthBar hpBar) { private int maxH;
public PolyjetEntity(AssetManager assets, float speed, float accel,int maxHealth, String jet) {
nonStnrd = true; nonStnrd = true;
health = 100; health = 100;
this.speed = speed; this.speed = speed;
this.accel = accel; this.accel = accel;
this.hpBar = hpBar;
setSize(1.5f, 1.5f); setSize(1.5f, 1.5f);
setPosition(RhythmBullet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f); setPosition(RhythmBullet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
maxH = maxHealth;
hitbox = new Rectangle(getX(), getY(), getWidth(), getHeight()); hitbox = new Rectangle(getX(), getY(), getWidth(), getHeight());
polyjet = assets.get("polyjet-" + jet + ".png", Texture.class); polyjet = assets.get("polyjet-" + jet + ".png", Texture.class);
thrust = assets.get("standard_thrust.p", ParticleEffect.class); thrust = assets.get("standard_thrust.p", ParticleEffect.class);
@ -72,8 +70,8 @@ public class PolyJetEntity extends Entity {
if (health <= 0) { if (health <= 0) {
dead = true; dead = true;
} else if (health > hpBar.getMaxHealth()) { } else if (health > maxH) {
health = hpBar.getMaxHealth(); health = maxH;
} }
super.act(delta); super.act(delta);
@ -95,7 +93,6 @@ public class PolyJetEntity extends Entity {
} }
public void setHealth(float health) { public void setHealth(float health) {
hpBar.setHealth(health);
this.health = health; this.health = health;
} }
} }

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Rectangle;
import zero1hd.rhythmbullet.RhythmBullet; import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.entity.Entity; import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.ally.PolyJetEntity; import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
public class Bar extends Entity { public class Bar extends Entity {
@ -47,7 +47,7 @@ public class Bar extends Entity {
@Override @Override
public void collided(Entity entity) { public void collided(Entity entity) {
if (entity.getClass() == PolyJetEntity.class) { if (entity.getClass() == PolyjetEntity.class) {
dead = true; dead = true;
} }
} }

View File

@ -25,8 +25,8 @@ public class CreativeScreen extends ScreenAdapter {
Preferences prefs; Preferences prefs;
public CreativeScreen(RhythmBullet core, MainMenu mainMenu) { public CreativeScreen(RhythmBullet core, MainMenu mainMenu) {
ghud = new GameHUD(core.getDefaultSkin(), 100f); gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs(), ghud); ghud = new GameHUD(core.getDefaultSkin(), 100f, gamePlayArea);
chud = new CreativeHUD(core, mainMenu, gamePlayArea); chud = new CreativeHUD(core, mainMenu, gamePlayArea);
inputs = new InputMultiplexer(chud, gamePlayArea); inputs = new InputMultiplexer(chud, gamePlayArea);

View File

@ -46,9 +46,8 @@ public class GameScreen extends ScreenAdapter {
} }
}); });
gameHUD = new GameHUD(core.getDefaultSkin(), 100f); gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs(), gameHUD); gameHUD = new GameHUD(core.getDefaultSkin(), 100f, gameArea);
inputs = new InputMultiplexer(); inputs = new InputMultiplexer();
inputs.addProcessor(gameHUD); inputs.addProcessor(gameHUD);
inputs.addProcessor(gameArea); inputs.addProcessor(gameArea);
@ -114,7 +113,7 @@ public class GameScreen extends ScreenAdapter {
//actual game and hud //actual game and hud
if (!gameHUD.isPaused()) { if (!gameHUD.isPaused()) {
gameArea.act(delta); gameArea.act(delta);
if (gameArea.getPolyjet().isDead()) { if (gameArea.getPolyjetEntity().isDead()) {
end(false); end(false);
} }
gameHUD.act(delta); gameHUD.act(delta);

View File

@ -6,11 +6,15 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup; import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
public class HealthBar extends WidgetGroup { public class HealthBar extends WidgetGroup {
Image empty; Image empty;
Image filler; Image filler;
float health; float health;
float maxHealth; float maxHealth;
PolyjetEntity pje;
public HealthBar(Skin skin, float maxHealth) { public HealthBar(Skin skin, float maxHealth) {
super(); super();
filler = new Image(skin.getPatch("bar-fill")); filler = new Image(skin.getPatch("bar-fill"));
@ -19,17 +23,28 @@ public class HealthBar extends WidgetGroup {
empty = new Image(skin.getPatch("bar-empty")); empty = new Image(skin.getPatch("bar-empty"));
addActor(empty); addActor(empty);
this.maxHealth = maxHealth; this.maxHealth = maxHealth;
} }
public void setPolyjetEntity(PolyjetEntity pje) {
this.pje = pje;
}
public void setHealth(float health) { public void setHealth(float health) {
this.health = health; this.health = health;
filler.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));; filler.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));;
} }
@Override
public void act(float delta) {
if (pje != null) {
health = pje.health;
}
super.act(delta);
}
@Override @Override
public void setSize(float width, float height) { public void setSize(float width, float height) {
empty.setSize(width, height); empty.setSize(width, height);

View File

@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image; import com.badlogic.gdx.scenes.scene2d.ui.Image;
@ -59,18 +58,23 @@ public class GameHUD extends Stage {
pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f); pauseMenu.setPosition((Gdx.graphics.getWidth()-pauseMenu.getWidth())/2f, (Gdx.graphics.getHeight()-pauseMenu.getHeight())/2f);
healthBar = new HealthBar(skin, maxHealth); healthBar = new HealthBar(skin, maxHealth);
healthBar.setSize(20f, Gdx.graphics.getHeight()/3); healthBar.setSize(30f, Gdx.graphics.getHeight()/3);
healthBar.setHealth(maxHealth); healthBar.setHealth(maxHealth);
healthBar.setPosition(Gdx.graphics.getWidth()-healthBar.getWidth() -10f, (Gdx.graphics.getHeight()-healthBar.getHeight())/2f); healthBar.setPosition(Gdx.graphics.getWidth()-healthBar.getWidth() -10f, (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
addActor(healthBar); addActor(healthBar);
healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
leftStatusBar = new Image(skin.getDrawable("gradient-bar")); leftStatusBar = new Image(skin.getDrawable("gradient-bar"));
leftStatusBar.setSize(20f, getHeight()); leftStatusBar.setSize(30f, getHeight());
leftStatusBar.setPosition(gpa.getViewport().getScreenX(), 0); leftStatusBar.setPosition(gpa.getViewport().getScreenX()-leftStatusBar.getWidth()/2f, 0);
addActor(leftStatusBar);
rightStatusBar = new Image(skin.getDrawable("gradient-bar")); rightStatusBar = new Image(skin.getDrawable("gradient-bar"));
rightStatusBar.setSize(20f, getHeight()); rightStatusBar.setSize(20f, getHeight());
rightStatusBar.setPosition(gpa.getViewport().getScreenX()+gpa.getViewport().getScreenWidth(), 0); rightStatusBar.setPosition(gpa.getViewport().getScreenX()+gpa.getViewport().getScreenWidth()-rightStatusBar.getWidth()/2f, 0);
addActor(rightStatusBar);
setStatusColor(1, 1, 1, 0.5f);
} }
/** /**
@ -132,6 +136,19 @@ public class GameHUD extends Stage {
this.music = music; this.music = music;
} }
public void setStatusColor(float r, float g, float b, float a) {
leftStatusBar.setColor(r, g, b, a);
rightStatusBar.setColor(r, g, b, a);
}
public void setLeftStatusColor(float r, float g, float b, float a) {
leftStatusBar.setColor(r, g, b, a);
}
public void setRightStatusColor(float r, float g, float b, float a) {
rightStatusBar.setColor(r, g, b, a);
}
public HealthBar getHealthBar() { public HealthBar getHealthBar() {
return healthBar; return healthBar;
} }

View File

@ -20,35 +20,33 @@ import zero1hd.rhythmbullet.entity.CollisionDetector;
import zero1hd.rhythmbullet.entity.Entity; import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityManager; import zero1hd.rhythmbullet.entity.EntityManager;
import zero1hd.rhythmbullet.entity.ally.Laser; import zero1hd.rhythmbullet.entity.ally.Laser;
import zero1hd.rhythmbullet.entity.ally.PolyJetEntity; import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager; import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager;
import zero1hd.rhythmbullet.util.ScoreManager;
public class GamePlayArea extends Stage { public class GamePlayArea extends Stage {
public PolyJetEntity polyjet; public PolyjetEntity polyjet;
private GamePlayMap audioMap; private GamePlayMap audioMap;
private GameHUD gameHUD;
public CoordinatorManager cm; public CoordinatorManager cm;
public EntityManager em; public EntityManager em;
private CollisionDetector collisionDetector; private CollisionDetector collisionDetector;
private int score; public ScoreManager score = new ScoreManager();
private ShaderProgram glowShader; private ShaderProgram glowShader;
private FrameBuffer blurTarget; private FrameBuffer blurTarget;
TextureRegion fboRegion; TextureRegion fboRegion;
private int fboSize; private int fboSize;
public GamePlayArea(AssetManager assetManager, Preferences prefs, GameHUD gameHUD) { public GamePlayArea(AssetManager assetManager, Preferences prefs) {
super(new FitViewport(RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT)); super(new FitViewport(RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT));
Gdx.app.debug("Game Area", "new area created"); Gdx.app.debug("Game Area", "new area created");
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard", gameHUD.getHealthBar()); polyjet = new PolyjetEntity(assetManager, 25f, 25f, 100, "standard");
em = new EntityManager(assetManager, prefs, this); em = new EntityManager(assetManager, prefs, this);
cm = new CoordinatorManager(em); cm = new CoordinatorManager(em);
this.gameHUD = gameHUD;
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs); collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
em.activeAllies.add(polyjet); em.activeAllies.add(polyjet);
@ -141,7 +139,7 @@ public class GamePlayArea extends Stage {
} }
collisionDetector.collisionCheck(); collisionDetector.collisionCheck();
addScore(collisionDetector.getAmassedPoints()); score.addScore(collisionDetector.getAmassedPoints());
if (polyjet.getX() <= 1) { if (polyjet.getX() <= 1) {
polyjet.moveLeft = false; polyjet.moveLeft = false;
@ -165,10 +163,6 @@ public class GamePlayArea extends Stage {
super.act(delta); super.act(delta);
} }
public void addScore (int score) {
setScore(this.score += score);
}
@Override @Override
public boolean keyDown(int keycode) { public boolean keyDown(int keycode) {
if (keycode == KeyMap.left) { if (keycode == KeyMap.left) {
@ -219,15 +213,10 @@ public class GamePlayArea extends Stage {
return false; return false;
} }
public PolyJetEntity getPolyjet() { public PolyjetEntity getPolyjetEntity() {
return polyjet; return polyjet;
} }
public void setScore(int score) {
this.score = score;
gameHUD.setScore(score);
}
@Override @Override
public void dispose() { public void dispose() {
if (glowShader != null) { if (glowShader != null) {

View File

@ -0,0 +1,17 @@
package zero1hd.rhythmbullet.util;
public class ScoreManager {
public int score;
public void setScore(int score) {
this.score = score;
}
public int getScore() {
return score;
}
public void addScore(int addedScore) {
score += addedScore;
}
}