added border to show status effects, preparing for better score system
This commit is contained in:
		@@ -319,3 +319,10 @@ large-pane
 | 
			
		||||
  orig: 9, 27
 | 
			
		||||
  offset: 0, 0
 | 
			
		||||
  index: -1
 | 
			
		||||
gradient-bar
 | 
			
		||||
  rotate: false
 | 
			
		||||
  xy: 26, 7
 | 
			
		||||
  size: 3, 1
 | 
			
		||||
  orig: 3, 1
 | 
			
		||||
  offset: 0, 0
 | 
			
		||||
  index: -1
 | 
			
		||||
@@ -9,26 +9,24 @@ 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 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, HealthBar hpBar) {
 | 
			
		||||
	private int maxH;
 | 
			
		||||
	public PolyjetEntity(AssetManager assets, float speed, float accel,int maxHealth, String jet) {
 | 
			
		||||
		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);
 | 
			
		||||
		
 | 
			
		||||
		maxH = maxHealth;
 | 
			
		||||
		hitbox = new Rectangle(getX(), getY(), getWidth(), getHeight());
 | 
			
		||||
		polyjet = assets.get("polyjet-" + jet + ".png", Texture.class);
 | 
			
		||||
		thrust = assets.get("standard_thrust.p", ParticleEffect.class);
 | 
			
		||||
@@ -72,8 +70,8 @@ public class PolyJetEntity extends Entity {
 | 
			
		||||
		
 | 
			
		||||
		if (health <= 0) {
 | 
			
		||||
			dead = true;
 | 
			
		||||
		} else if (health > hpBar.getMaxHealth()) {
 | 
			
		||||
			health = hpBar.getMaxHealth();
 | 
			
		||||
		} else if (health > maxH) {
 | 
			
		||||
			health = maxH;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		super.act(delta);
 | 
			
		||||
@@ -95,7 +93,6 @@ public class PolyJetEntity extends Entity {
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setHealth(float health) {
 | 
			
		||||
		hpBar.setHealth(health);
 | 
			
		||||
		this.health = health;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Rectangle;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.RhythmBullet;
 | 
			
		||||
import zero1hd.rhythmbullet.entity.Entity;
 | 
			
		||||
import zero1hd.rhythmbullet.entity.ally.PolyJetEntity;
 | 
			
		||||
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
 | 
			
		||||
 | 
			
		||||
public class Bar extends Entity {
 | 
			
		||||
	
 | 
			
		||||
@@ -47,7 +47,7 @@ public class Bar extends Entity {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void collided(Entity entity) {
 | 
			
		||||
		if (entity.getClass() == PolyJetEntity.class) {
 | 
			
		||||
		if (entity.getClass() == PolyjetEntity.class) {
 | 
			
		||||
			dead = true;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,8 @@ public class CreativeScreen extends ScreenAdapter {
 | 
			
		||||
	Preferences prefs;
 | 
			
		||||
	
 | 
			
		||||
	public CreativeScreen(RhythmBullet core, MainMenu mainMenu) {
 | 
			
		||||
		ghud = new GameHUD(core.getDefaultSkin(), 100f);
 | 
			
		||||
		gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs(), ghud);
 | 
			
		||||
		gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
 | 
			
		||||
		ghud = new GameHUD(core.getDefaultSkin(), 100f, gamePlayArea);
 | 
			
		||||
		chud = new CreativeHUD(core, mainMenu, gamePlayArea);
 | 
			
		||||
		inputs = new InputMultiplexer(chud, gamePlayArea);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -46,9 +46,8 @@ public class GameScreen extends ScreenAdapter {
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
		
 | 
			
		||||
		gameHUD = new GameHUD(core.getDefaultSkin(), 100f);
 | 
			
		||||
		gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs(), gameHUD);
 | 
			
		||||
		
 | 
			
		||||
		gameArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
 | 
			
		||||
		gameHUD = new GameHUD(core.getDefaultSkin(), 100f, gameArea);
 | 
			
		||||
		inputs = new InputMultiplexer();
 | 
			
		||||
		inputs.addProcessor(gameHUD);
 | 
			
		||||
		inputs.addProcessor(gameArea);
 | 
			
		||||
@@ -114,7 +113,7 @@ public class GameScreen extends ScreenAdapter {
 | 
			
		||||
		//actual game and hud
 | 
			
		||||
		if (!gameHUD.isPaused()) {
 | 
			
		||||
			gameArea.act(delta);
 | 
			
		||||
			if (gameArea.getPolyjet().isDead()) {
 | 
			
		||||
			if (gameArea.getPolyjetEntity().isDead()) {
 | 
			
		||||
				end(false);
 | 
			
		||||
			}
 | 
			
		||||
			gameHUD.act(delta);
 | 
			
		||||
 
 | 
			
		||||
@@ -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.WidgetGroup;
 | 
			
		||||
 | 
			
		||||
import zero1hd.rhythmbullet.entity.ally.PolyjetEntity;
 | 
			
		||||
 | 
			
		||||
public class HealthBar extends WidgetGroup {
 | 
			
		||||
	Image empty;
 | 
			
		||||
	Image filler;
 | 
			
		||||
	float health;
 | 
			
		||||
	float maxHealth;
 | 
			
		||||
	
 | 
			
		||||
	PolyjetEntity pje;
 | 
			
		||||
	public HealthBar(Skin skin, float maxHealth) {
 | 
			
		||||
		super();
 | 
			
		||||
		filler = new Image(skin.getPatch("bar-fill"));
 | 
			
		||||
@@ -19,17 +23,28 @@ public class HealthBar extends WidgetGroup {
 | 
			
		||||
		empty = new Image(skin.getPatch("bar-empty"));
 | 
			
		||||
		addActor(empty);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		this.maxHealth = maxHealth;
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setPolyjetEntity(PolyjetEntity pje) {
 | 
			
		||||
		this.pje = pje;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setHealth(float health) {
 | 
			
		||||
		this.health = health;
 | 
			
		||||
		
 | 
			
		||||
		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
 | 
			
		||||
	public void setSize(float width, float height) {
 | 
			
		||||
		empty.setSize(width, height);
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx;
 | 
			
		||||
import com.badlogic.gdx.Input.Keys;
 | 
			
		||||
import com.badlogic.gdx.audio.Music;
 | 
			
		||||
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.Stage;
 | 
			
		||||
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);
 | 
			
		||||
		
 | 
			
		||||
		healthBar = new HealthBar(skin, maxHealth);
 | 
			
		||||
		healthBar.setSize(20f, Gdx.graphics.getHeight()/3);
 | 
			
		||||
		healthBar.setSize(30f, Gdx.graphics.getHeight()/3);
 | 
			
		||||
		healthBar.setHealth(maxHealth);
 | 
			
		||||
		healthBar.setPosition(Gdx.graphics.getWidth()-healthBar.getWidth() -10f, (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
 | 
			
		||||
		addActor(healthBar);
 | 
			
		||||
		healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
 | 
			
		||||
		
 | 
			
		||||
		leftStatusBar = new Image(skin.getDrawable("gradient-bar"));
 | 
			
		||||
		leftStatusBar.setSize(20f, getHeight());
 | 
			
		||||
		leftStatusBar.setPosition(gpa.getViewport().getScreenX(), 0);
 | 
			
		||||
		leftStatusBar.setSize(30f, getHeight());
 | 
			
		||||
		leftStatusBar.setPosition(gpa.getViewport().getScreenX()-leftStatusBar.getWidth()/2f, 0);
 | 
			
		||||
		addActor(leftStatusBar);
 | 
			
		||||
		
 | 
			
		||||
		rightStatusBar = new Image(skin.getDrawable("gradient-bar"));
 | 
			
		||||
		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;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	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() {
 | 
			
		||||
		return healthBar;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -20,35 +20,33 @@ import zero1hd.rhythmbullet.entity.CollisionDetector;
 | 
			
		||||
import zero1hd.rhythmbullet.entity.Entity;
 | 
			
		||||
import zero1hd.rhythmbullet.entity.EntityManager;
 | 
			
		||||
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.util.ScoreManager;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class GamePlayArea extends Stage {
 | 
			
		||||
	public PolyJetEntity polyjet;
 | 
			
		||||
	public PolyjetEntity polyjet;
 | 
			
		||||
	private GamePlayMap audioMap;
 | 
			
		||||
	
 | 
			
		||||
	private GameHUD gameHUD;
 | 
			
		||||
	
 | 
			
		||||
	public CoordinatorManager cm;
 | 
			
		||||
	public EntityManager em;
 | 
			
		||||
	private CollisionDetector collisionDetector;
 | 
			
		||||
	
 | 
			
		||||
	private int score;
 | 
			
		||||
	public ScoreManager score = new ScoreManager();
 | 
			
		||||
	
 | 
			
		||||
	private ShaderProgram glowShader;
 | 
			
		||||
	private FrameBuffer blurTarget;
 | 
			
		||||
	TextureRegion fboRegion;
 | 
			
		||||
	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));
 | 
			
		||||
		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);
 | 
			
		||||
		cm = new CoordinatorManager(em);
 | 
			
		||||
		this.gameHUD = gameHUD;
 | 
			
		||||
		
 | 
			
		||||
		collisionDetector = new CollisionDetector(em.activeEnemies, em.activeAllies, assetManager, prefs);
 | 
			
		||||
		em.activeAllies.add(polyjet);
 | 
			
		||||
@@ -141,7 +139,7 @@ public class GamePlayArea extends Stage {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		collisionDetector.collisionCheck();
 | 
			
		||||
		addScore(collisionDetector.getAmassedPoints());
 | 
			
		||||
		score.addScore(collisionDetector.getAmassedPoints());
 | 
			
		||||
		
 | 
			
		||||
		if (polyjet.getX() <= 1) {
 | 
			
		||||
			polyjet.moveLeft = false;
 | 
			
		||||
@@ -165,10 +163,6 @@ public class GamePlayArea extends Stage {
 | 
			
		||||
		super.act(delta);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void addScore (int score) {
 | 
			
		||||
		setScore(this.score += score);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean keyDown(int keycode) {
 | 
			
		||||
		if (keycode == KeyMap.left) {
 | 
			
		||||
@@ -219,15 +213,10 @@ public class GamePlayArea extends Stage {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public PolyJetEntity getPolyjet() {
 | 
			
		||||
	public PolyjetEntity getPolyjetEntity() {
 | 
			
		||||
		return polyjet;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void setScore(int score) {
 | 
			
		||||
		this.score = score;
 | 
			
		||||
		gameHUD.setScore(score);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void dispose() {
 | 
			
		||||
		if (glowShader != null) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								core/src/zero1hd/rhythmbullet/util/ScoreManager.java
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										17
									
								
								core/src/zero1hd/rhythmbullet/util/ScoreManager.java
									
									
									
									
									
										Executable 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;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user