gradients for sides better implemented

This commit is contained in:
Harrison Deng 2017-08-10 01:45:22 -05:00
parent 85117f74aa
commit aad923ea48
6 changed files with 70 additions and 39 deletions

View File

@ -319,10 +319,3 @@ 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -74,6 +74,26 @@ public class PolyjetEntity extends Entity {
health = maxH; health = maxH;
} }
if (getX() <= 1) {
moveLeft = false;
setX(1f);
}
if (getX() >= RhythmBullet.GAME_AREA_WIDTH-1-getWidth()) {
moveRight = false;
setX(RhythmBullet.GAME_AREA_WIDTH-1f-getWidth());
}
if (getY() >= RhythmBullet.GAME_AREA_HEIGHT - 1 - getHeight()) {
moveUp = false;
setY(RhythmBullet.GAME_AREA_HEIGHT - 1 - getHeight());
}
if (getY() <= 1) {
moveDown = false;
setY(1f);
}
super.act(delta); super.act(delta);
} }

View File

@ -28,7 +28,7 @@ public class CreativeScreen extends ScreenAdapter {
gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs()); gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
ghud = new GameHUD(core.getDefaultSkin(), 100f, gamePlayArea); 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, ghud, gamePlayArea);
this.prefs = core.getPrefs(); this.prefs = core.getPrefs();

View File

@ -4,6 +4,10 @@ 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.Pixmap;
import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
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;
@ -24,6 +28,9 @@ public class GameHUD extends Stage {
private FPSWindow fpsWindow; private FPSWindow fpsWindow;
private PauseMenu pauseMenu; private PauseMenu pauseMenu;
private HealthBar healthBar; private HealthBar healthBar;
private Pixmap pixmap;
private Texture leftStatTexture;
private Texture rightStatTexture;
private Image leftStatusBar; private Image leftStatusBar;
private Image rightStatusBar; private Image rightStatusBar;
private Music music; private Music music;
@ -61,21 +68,40 @@ public class GameHUD extends Stage {
healthBar = new HealthBar(skin, maxHealth); healthBar = new HealthBar(skin, maxHealth);
healthBar.setSize(30f, 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() -(gpa.getViewport().getRightGutterWidth()/4f), (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
addActor(healthBar); addActor(healthBar);
healthBar.setPolyjetEntity(gpa.getPolyjetEntity()); healthBar.setPolyjetEntity(gpa.getPolyjetEntity());
leftStatusBar = new Image(skin.getDrawable("gradient-bar")); pixmap = new Pixmap(3, 3, Format.RGBA8888);
leftStatusBar.setSize(30f, getHeight()); int excess = 2*gpa.getViewport().getLeftGutterWidth()/pixmap.getWidth();
leftStatusBar.setPosition(gpa.getViewport().getScreenX()-leftStatusBar.getWidth()/2f, 0); Gdx.app.debug("GHUD", "offset on size: " + excess);
pixmap.setColor(Color.WHITE);
pixmap.drawLine(0, 0, 0, 2);
pixmap.setColor(1f, 1f, 1f, 0.5f);
pixmap.drawLine(1, 0, 1, 2);
leftStatTexture = new Texture(pixmap);
leftStatTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
leftStatusBar = new Image(leftStatTexture);
leftStatusBar.setSize(gpa.getViewport().getLeftGutterWidth()+excess, getHeight());
leftStatusBar.setPosition(0, 0);
addActor(leftStatusBar); addActor(leftStatusBar);
leftStatusBar.toBack();
rightStatusBar = new Image(skin.getDrawable("gradient-bar")); pixmap.dispose();
rightStatusBar.setSize(20f, getHeight()); pixmap = new Pixmap(3, 3, Format.RGBA8888);
rightStatusBar.setPosition(gpa.getViewport().getScreenX()+gpa.getViewport().getScreenWidth()-rightStatusBar.getWidth()/2f, 0); pixmap.setColor(Color.WHITE);
pixmap.drawLine(2, 0, 2, 2);
pixmap.setColor(1f, 1f, 1f, 0.5f);
pixmap.drawLine(1, 0, 1, 2);
rightStatTexture = new Texture(pixmap);
rightStatTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
rightStatusBar = new Image(rightStatTexture);
rightStatusBar.setSize(gpa.getViewport().getRightGutterWidth()+excess, getHeight());
rightStatusBar.setPosition(getWidth()-gpa.getViewport().getRightGutterWidth()-excess, 0f);
addActor(rightStatusBar); addActor(rightStatusBar);
rightStatusBar.toBack();
setStatusColor(1, 1, 1, 0.5f); pixmap.dispose();
setStatusColor(0.0f, 1f, 1f, 0.7f);
} }
@Override @Override
@ -97,11 +123,15 @@ public class GameHUD extends Stage {
public void setPaused(boolean paused) { public void setPaused(boolean paused) {
if (paused) { if (paused) {
addActor(pauseMenu); addActor(pauseMenu);
if (music != null) {
music.pause(); music.pause();
}
} else { } else {
pauseMenu.remove(); pauseMenu.remove();
if (music != null) {
music.play(); music.play();
} }
}
this.paused = paused; this.paused = paused;
} }
@ -161,4 +191,11 @@ public class GameHUD extends Stage {
public HealthBar getHealthBar() { public HealthBar getHealthBar() {
return healthBar; return healthBar;
} }
@Override
public void dispose() {
leftStatTexture.dispose();
rightStatTexture.dispose();
super.dispose();
}
} }

View File

@ -141,25 +141,6 @@ public class GamePlayArea extends Stage {
collisionDetector.collisionCheck(); collisionDetector.collisionCheck();
score.addScore(collisionDetector.getAmassedPoints()); score.addScore(collisionDetector.getAmassedPoints());
if (polyjet.getX() <= 1) {
polyjet.moveLeft = false;
polyjet.setX(1f);
}
if (polyjet.getX() >= RhythmBullet.GAME_AREA_WIDTH-1-polyjet.getWidth()) {
polyjet.moveRight = false;
polyjet.setX(RhythmBullet.GAME_AREA_WIDTH-1f-polyjet.getWidth());
}
if (polyjet.getY() >= RhythmBullet.GAME_AREA_HEIGHT - 1 - polyjet.getHeight()) {
polyjet.moveUp = false;
polyjet.setY(RhythmBullet.GAME_AREA_HEIGHT - 1 - polyjet.getHeight());
}
if (polyjet.getY() <= 1) {
polyjet.moveDown = false;
polyjet.setY(1f);
}
super.act(delta); super.act(delta);
} }