added groundwork for scoring and minor tweaks to textures

This commit is contained in:
Harrison Deng 2017-08-04 02:00:20 -05:00
parent 4915190fdb
commit 0101f0630b
22 changed files with 95 additions and 66 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 616 KiB

After

Width:  |  Height:  |  Size: 738 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 799 KiB

After

Width:  |  Height:  |  Size: 947 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 754 KiB

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 KiB

After

Width:  |  Height:  |  Size: 424 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -195,6 +195,9 @@ public class RhythmBullet extends Game {
subTextbutton.font = getDefaultSkin().getFont("sub-font");
getDefaultSkin().add("sub", subTextbutton);
TextButtonStyle windowTextButton = new TextButtonStyle(defaultTextButton);
windowTextButton.font = getDefaultSkin().getFont("window-font");
getDefaultSkin().add("window", windowTextButton);
TextButtonStyle textButtonLeft = new TextButtonStyle();
textButtonLeft.up = getDefaultSkin().getDrawable("left-button");

View File

@ -23,6 +23,7 @@ public class CollisionDetector {
ParticleEffectPool explosionEffectPool;
Array<PooledEffect> effects = new Array<>();
private int amassedPoints;
Sound explosionSFX;
public CollisionDetector(Array<Entity> enemies, Array<Entity> allies, AssetManager assetManager, Preferences prefs) {
this.enemies = enemies;
@ -58,6 +59,8 @@ public class CollisionDetector {
enemy.collided(ally);
ally.collided(enemy);
amassedPoints += enemy.getPoints();
break;
}
}
@ -89,4 +92,10 @@ public class CollisionDetector {
batch.end();
}
}
public int getAmassedPoints() {
int amassedPoints = this.amassedPoints;
this.amassedPoints = 0;
return amassedPoints;
}
}

View File

@ -37,7 +37,7 @@ public class Entity extends Actor implements Poolable {
public float angle;
public float speed;
protected int points;
/**
* called by the entity frame and only once (when this object is created).
@ -162,6 +162,7 @@ public class Entity extends Actor implements Poolable {
center.set(0, 0);
angle = 0;
speed = 0;
points = 0;
dead = false;
}
@ -185,4 +186,8 @@ public class Entity extends Actor implements Poolable {
this.coordinator = coordinator;
coordinator.setEntity(this);
}
public int getPoints() {
return points + (coordinator != null ? coordinator.getScoreBonus() : 0);
}
}

View File

@ -9,21 +9,23 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.ui.builders.HealthBar;
public class PolyJetEntity extends Entity {
public float health;
private ParticleEffect thrust;
private Texture polyjet;
private ParticleEffect teleportCloak;
private HealthBar hpBar;
public boolean moveLeft, moveRight, moveUp, moveDown, teleporting, accelerate;
private float speed, accel;
private float rate;
public PolyJetEntity(AssetManager assets, float speed, float accel, String jet) {
public PolyJetEntity(AssetManager assets, float speed, float accel, String jet, HealthBar hpBar) {
nonStnrd = true;
health = 100;
this.speed = speed;
this.accel = accel;
this.hpBar = hpBar;
setSize(1.5f, 1.5f);
setPosition(RhythmBullet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
@ -70,6 +72,8 @@ public class PolyJetEntity extends Entity {
if (health <= 0) {
dead = true;
} else if (health > hpBar.getMaxHealth()) {
health = hpBar.getMaxHealth();
}
super.act(delta);
@ -89,4 +93,9 @@ public class PolyJetEntity extends Entity {
public Rectangle getHitbox() {
return hitbox;
}
public void setHealth(float health) {
hpBar.setHealth(health);
this.health = health;
}
}

View File

@ -9,6 +9,7 @@ public class Coordinator implements Poolable {
private CoordinatorFrame<? extends Coordinator> cf;
protected EntityManager em;
protected Entity entity;
protected int scoreBonus;
public void setup(EntityManager em, CoordinatorFrame<? extends Coordinator> cf) {
this.em = em;
@ -34,4 +35,8 @@ public class Coordinator implements Poolable {
public void reset() {
entity = null;
}
public int getScoreBonus() {
return scoreBonus;
}
}

View File

@ -24,7 +24,6 @@ public class Pellet extends Entity implements Poolable {
this.angle = angle;
}
/**
* Vars: x, y, speed, angle;
*/

View File

@ -10,10 +10,12 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.ui.stages.CreativeHUD;
import zero1hd.rhythmbullet.ui.stages.GameHUD;
import zero1hd.rhythmbullet.ui.stages.GamePlayArea;
public class CreativeDebugScreen extends ScreenAdapter {
CreativeHUD creative;
public class CreativeScreen extends ScreenAdapter {
CreativeHUD chud;
GameHUD ghud;
GamePlayArea gamePlayArea;
InputMultiplexer inputs;
@ -22,11 +24,11 @@ public class CreativeDebugScreen extends ScreenAdapter {
Preferences prefs;
public CreativeDebugScreen(RhythmBullet core, MainMenu mainMenu) {
gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
creative = new CreativeHUD(core, mainMenu, gamePlayArea);
inputs = new InputMultiplexer(creative, gamePlayArea);
public CreativeScreen(RhythmBullet core, MainMenu mainMenu) {
ghud = new GameHUD(core.getDefaultSkin(), 100f);
gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs(), ghud);
chud = new CreativeHUD(core, mainMenu, gamePlayArea);
inputs = new InputMultiplexer(chud, gamePlayArea);
this.prefs = core.getPrefs();
@ -55,9 +57,13 @@ public class CreativeDebugScreen extends ScreenAdapter {
gamePlayArea.act();
gamePlayArea.draw();
creative.getViewport().apply();
creative.act();
creative.draw();
ghud.getViewport().apply();
ghud.act();
ghud.draw();
chud.getViewport().apply();
chud.act();
chud.draw();
super.render(delta);
}

View File

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

View File

@ -9,9 +9,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
public class HealthBar extends WidgetGroup {
Image empty;
Image filler;
int health;
int maxHealth;
public HealthBar(Skin skin, int maxHealth) {
float health;
float maxHealth;
public HealthBar(Skin skin, float maxHealth) {
super();
filler = new Image(skin.getPatch("bar-fill"));
addActor(filler);
@ -24,7 +24,7 @@ public class HealthBar extends WidgetGroup {
}
public void setHealth(int health) {
public void setHealth(float health) {
this.health = health;
filler.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));;
@ -49,4 +49,8 @@ public class HealthBar extends WidgetGroup {
empty.setHeight(height);
super.setHeight(height);
}
public float getMaxHealth() {
return maxHealth;
}
}

View File

@ -17,7 +17,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.rhythmbullet.RhythmBullet;
import zero1hd.rhythmbullet.screens.CreativeDebugScreen;
import zero1hd.rhythmbullet.screens.CreativeScreen;
import zero1hd.rhythmbullet.screens.MainMenu;
public class OptionsPage extends Page {
@ -152,7 +152,7 @@ public class OptionsPage extends Page {
if (core.getAssetManager().update() && goToScreen != 0) {
switch (goToScreen) {
case 1:
core.setScreen(new CreativeDebugScreen(core, (MainMenu) core.getScreen()));
core.setScreen(new CreativeScreen(core, (MainMenu) core.getScreen()));
}
goToScreen = 0;
}

View File

@ -59,8 +59,14 @@ public class CreativeHUD extends Stage implements MiniListener {
spawnerWindow = new SpawnerWindow("Spawn Tool", core.getDefaultSkin(), gpa.em, gpa.cm, gpa);
diffWindow = new DifficultyWindow(core.getDefaultSkin());
toolbox = new Window("Tools", core.getDefaultSkin(), "tinted");
toolbox.defaults().pad(5f);
Table toolboxToolSet = new Table(core.getDefaultSkin());
toolboxToolSet.defaults().space(5f).left();
//Back button
TextButton backButton = new TextButton("Back", core.getDefaultSkin());
TextButton backButton = new TextButton("Back", core.getDefaultSkin(), "window");
backButton.addListener(new ChangeListener() {
@Override
@ -69,15 +75,8 @@ public class CreativeHUD extends Stage implements MiniListener {
core.setScreen(mainMenu);
}
});
backButton.setPosition(10, Gdx.graphics.getHeight()-backButton.getHeight()-10);
addActor(backButton);
toolbox = new Window("Tools", core.getDefaultSkin(), "tinted");
toolbox.defaults().pad(5f);
Table toolboxToolSet = new Table(core.getDefaultSkin());
toolboxToolSet.defaults().space(5f);
toolboxToolSet.add(backButton);
toolboxToolSet.row();
final CheckBox musicSelectorCheckbox = new CheckBox(" Music selector", core.getDefaultSkin());
musicSelectorCheckbox.addListener(new ChangeListener() {
@ -200,8 +199,7 @@ public class CreativeHUD extends Stage implements MiniListener {
toolboxToolSet.add(diffAdjusterCheckBox);
ScrollPane scroller = new ScrollPane(toolboxToolSet, core.getDefaultSkin());
toolbox.add(scroller).expand().fill();
toolbox.setSize(300, 300);
toolbox.add(scroller).height(250f).width(150f);
addActor(toolbox);
addListener(new InputListener() {
@ -213,7 +211,6 @@ public class CreativeHUD extends Stage implements MiniListener {
return super.keyUp(event, keycode);
}
});
toolboxToolSet.pack();
toolbox.pack();
}

View File

@ -16,7 +16,7 @@ import zero1hd.rhythmbullet.ui.windows.FPSWindow;
import zero1hd.rhythmbullet.ui.windows.PauseMenu;
public class GameHUD extends Stage {
private Label score;
private Label scoreLabel;
private ImageButton pause;
private boolean paused;
private FPSWindow fpsWindow;
@ -25,11 +25,11 @@ public class GameHUD extends Stage {
private Music music;
public GameHUD(Skin skin, int maxHealth) {
public GameHUD(Skin skin, float maxHealth) {
super();
score = new Label("Score: 0", skin, "default-font", Color.WHITE);
score.setPosition(10f, Gdx.graphics.getHeight()-score.getHeight() - 10f);
addActor(score);
scoreLabel = new Label("Score: 0", skin, "default-font", Color.WHITE);
scoreLabel.setPosition(10f, Gdx.graphics.getHeight()-scoreLabel.getHeight() - 10f);
addActor(scoreLabel);
pause = new ImageButton(skin.getDrawable("pause"),
skin.getDrawable("pause-down"));
@ -67,15 +67,7 @@ public class GameHUD extends Stage {
* @param score designated score
*/
public void setScore(int score) {
this.score.setText("Score: " + score);
}
/**
* returns current score by use of substring
* @return the current score value
*/
public int getScore() {
return Integer.valueOf(score.getText().substring(7));
this.scoreLabel.setText("Score: " + score);
}
public void setPaused(boolean paused) {
@ -128,4 +120,8 @@ public class GameHUD extends Stage {
public void setMusic(Music music) {
this.music = music;
}
public HealthBar getHealthBar() {
return healthBar;
}
}

View File

@ -28,12 +28,12 @@ public class GamePlayArea extends Stage {
public PolyJetEntity polyjet;
private GamePlayMap audioMap;
private GameHUD gameHUD;
public CoordinatorManager cm;
public EntityManager em;
private CollisionDetector collisionDetector;
private int maxHealth = 100;
private float yTeleport = RhythmBullet.GAME_AREA_HEIGHT/2;
private int score;
@ -43,13 +43,15 @@ public class GamePlayArea extends Stage {
TextureRegion fboRegion;
private int fboSize;
public GamePlayArea(AssetManager assetManager, Preferences prefs) {
public GamePlayArea(AssetManager assetManager, Preferences prefs, GameHUD gameHUD) {
super(new FitViewport(RhythmBullet.GAME_AREA_WIDTH, RhythmBullet.GAME_AREA_HEIGHT));
Gdx.app.debug("Game Area", "new area created");
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard");
polyjet = new PolyJetEntity(assetManager, 25f, 25f, "standard", gameHUD.getHealthBar());
em = new EntityManager(assetManager, prefs, this);
cm = new CoordinatorManager(em);
this.gameHUD = gameHUD;
collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
em.activeAllies.add(polyjet);
addActor(polyjet);
@ -141,6 +143,7 @@ public class GamePlayArea extends Stage {
}
collisionDetector.collisionCheck();
addScore(collisionDetector.getAmassedPoints());
if (polyjet.getX() <= 1) {
polyjet.moveLeft = false;
@ -165,11 +168,7 @@ public class GamePlayArea extends Stage {
}
public void addScore (int score) {
this.score += score;
polyjet.health += score;
if (polyjet.health > maxHealth) {
polyjet.health = maxHealth;
}
setScore(this.score += score);
}
@Override
@ -226,13 +225,11 @@ public class GamePlayArea extends Stage {
return polyjet;
}
public int getScore() {
return score;
public void setScore(int score) {
this.score = score;
gameHUD.setScore(score);
}
public int getMaxHealth() {
return maxHealth;
}
public float getyTeleport() {
return yTeleport;
}