began setup of actual game screen

This commit is contained in:
Harrison Deng 2017-07-22 18:40:32 -05:00
parent 8a64368b9b
commit 99e6fe9c3f
45 changed files with 359 additions and 263 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 971 B

BIN
android/assets/800x480/magic1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

View File

@ -237,18 +237,18 @@ pause-down
index: -1
bar-empty
rotate: false
xy: 106, 13
size: 26, 7
split: 0, 0, 1, 1
orig: 32, 32
xy: 105, 13
size: 13, 3
split: 0, 0, 0, 0
orig: 13, 3
offset: 0, 0
index: -1
bar-fill
rotate: false
xy: 106, 21
size: 26, 7
split: 0, 0, 1, 1
orig: 26, 7
xy: 119, 13
size: 13, 3
split: 1, 1, 1, 1
orig: 13, 3
offset: 0, 0
index: -1
left-button

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -4,13 +4,13 @@ import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new Polyjet(), config);
initialize(new Main(), config);
}
}

View File

@ -36,7 +36,7 @@ import zero1hd.polyjet.util.GenericFileTypeHandler;
import zero1hd.polyjet.util.RoundingResolutionHandler;
import zero1hd.polyjet.screens.LoadingScreen;
public class Polyjet extends Game {
public class Main extends Game {
private boolean initComplete = false;
public static final int GAME_AREA_WIDTH = 64;
@ -134,6 +134,8 @@ public class Polyjet extends Game {
assetManager.load("explosion.ogg", Sound.class);
assetManager.load("disintegrate.ogg", Sound.class);
assetManager.load("explosion-s.p", ParticleEffect.class);
assetManager.load("tpSelector.png", Texture.class);
assetManager.load("magic1.png", Texture.class);
}
public void generateFonts() {
initComplete = true;

View File

@ -5,7 +5,7 @@ import org.apache.commons.math3.random.MersenneTwister;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.FloatArray;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.util.MiniEvents;
@ -59,29 +59,29 @@ public class RhythmMapAlgorithm implements Runnable {
if (bassPeaks.get(index) >= avgBass) {
//TODO basic void circle spawning
float warningTime = map.goBack((int) (windowPerSecond*1.5f))/windowPerSecond;
float endRadius = (bassPeaks.get(index)/bassMax)*(Polyjet.GAME_AREA_HEIGHT/4f);
float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f);
map.addToMap(Entities.VOID_CIRCLE,
endRadius,
rand.nextFloat()*Polyjet.GAME_AREA_WIDTH,
rand.nextFloat()*Polyjet.GAME_AREA_HEIGHT,
rand.nextFloat()*Main.GAME_AREA_WIDTH,
rand.nextFloat()*Main.GAME_AREA_HEIGHT,
endRadius/(avgSPB*0.7f),
warningTime
);
map.resetIndex();
}
if (UMPeaks.get(index) >= avgUM) {
int spawnLocations = (Polyjet.GAME_AREA_WIDTH-8)/8;
int spawnLocations = (Main.GAME_AREA_WIDTH-8)/8;
map.addToMap(Entities.BAR,
MathUtils.round(rand.nextFloat()*spawnLocations)*8,
(8f/avgSPB)*speedMod);
} else {
if (UMPeaks.get(index) != 0) {
float xSpawnLocation = (rand.nextFloat()*(Polyjet.GAME_AREA_WIDTH-2))+1;
float xSpawnLocation = (rand.nextFloat()*(Main.GAME_AREA_WIDTH-2))+1;
map.addToMap(Entities.PELLET,
xSpawnLocation,
Polyjet.GAME_AREA_HEIGHT-0.25f,
Main.GAME_AREA_HEIGHT-0.25f,
140*rand.nextFloat()+110f,
(Polyjet.GAME_AREA_HEIGHT/4f)/avgSPB);
(Main.GAME_AREA_HEIGHT/4f)/avgSPB);
}
}
} else {

View File

@ -6,7 +6,7 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
public class KeyMap {
TextureAtlas keyTextures;
@ -61,7 +61,7 @@ public class KeyMap {
public static int accelerate;
public KeyMap(Polyjet core) {
public KeyMap(Main core) {
keyTextures = core.getAssetManager().get("keyboard.atlas", TextureAtlas.class);
setKeys(Gdx.app.getPreferences("PolyJet_Controls"));

View File

@ -10,7 +10,7 @@ import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
import com.badlogic.gdx.utils.Array;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
public class CollisionDetector {
Array<Entity> firstGroup;
@ -45,7 +45,7 @@ public class CollisionDetector {
//Play FX;
if (se.playCollideSFX() && fe.playCollideSFX()) {
explosionSFX.play(prefs.getFloat("fx vol"), 1f, (fe.getX()/Polyjet.GAME_AREA_WIDTH)-0.55f);
explosionSFX.play(prefs.getFloat("fx vol"), 1f, (fe.getX()/Main.GAME_AREA_WIDTH)-0.55f);
}
if (se.playCollidePFX() && fe.playCollidePFX()) {
PooledEffect currentPFX;

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.entity.Entity;
@ -45,7 +45,7 @@ public class Laser extends Entity implements Poolable {
hitBox.setY(getY());
super.act(delta);
if (getY() > Polyjet.GAME_AREA_HEIGHT) {
if (getY() > Main.GAME_AREA_HEIGHT) {
dead = true;
}
}

View File

@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.entity.Entity;
@ -26,7 +26,7 @@ public class PolyJetEntity extends Entity {
this.speed = speed;
this.accel = accel;
setSize(1.5f, 1.5f);
setPosition(Polyjet.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
setPosition(Main.GAME_AREA_WIDTH/2 - getWidth()/2, -4f);
hitbox = new Rectangle(getX(), getY(), getWidth(), getHeight());
polyjet = assets.get("polyjet-" + jet + ".png", Texture.class);

View File

@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.entity.Entity;
@ -22,7 +22,7 @@ public class Bar extends Entity implements Poolable {
public void init(float x, float rate) {
setSize(8f, 0.5f);
setPosition(x, Polyjet.GAME_AREA_HEIGHT);
setPosition(x, Main.GAME_AREA_HEIGHT);
this.rate = rate;
hitbox.set(getX(), getY(), getWidth(), getHeight());
}

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.entity.Entity;
@ -53,7 +53,7 @@ public class Flake extends Entity implements Poolable {
hitbox.setPosition(getX(), getY());
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
timer = 0;
}
super.act(delta);

View File

@ -9,7 +9,7 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.entity.Entity;
@ -40,7 +40,7 @@ public class Pellet extends Entity implements Poolable {
hitBox.setPosition(getX(), getY());
super.act(delta);
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
dead = true;
}
}

View File

@ -9,7 +9,7 @@ import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.entity.Entities;
import zero1hd.polyjet.entity.Entity;
@ -61,7 +61,7 @@ public class Shard extends Entity implements Poolable {
moveBy(angle.x*delta*rate, angle.y*rate*delta);
hitbox.setPosition(getX(), getY());
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
hp = 0;
}
super.act(delta);

View File

@ -6,20 +6,20 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.ui.stages.CreativeStage;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.ui.stages.CreativeHUD;
import zero1hd.polyjet.ui.stages.GamePlayArea;
public class CreativeDebugScreen extends ScreenAdapter {
CreativeStage creative;
CreativeHUD creative;
GamePlayArea gamePlayArea;
InputMultiplexer inputs;
Preferences prefs;
public CreativeDebugScreen(Polyjet core, MainMenu mainMenu) {
public CreativeDebugScreen(Main core, MainMenu mainMenu) {
gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs());
creative = new CreativeStage(core, mainMenu, gamePlayArea);
creative = new CreativeHUD(core, mainMenu, gamePlayArea);
inputs = new InputMultiplexer(creative, gamePlayArea);

View File

@ -1,51 +1,33 @@
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.AudioData;
import zero1hd.polyjet.audio.map.GamePlayMap;
import zero1hd.polyjet.ui.stages.GameHUD;
import zero1hd.polyjet.ui.stages.GamePlayArea;
import zero1hd.polyjet.ui.windows.FPSWindow;
public class GameScreen extends ScreenAdapter implements InputProcessor {
public class GameScreen extends ScreenAdapter {
private GamePlayArea gameArea;
private GameHUD gameHUD;
public InputMultiplexer inputs;
public boolean paused = false;
private boolean debug = false;
public Polyjet core;
public Stage overlay;
private Label scoreLabel;
Window pauseMenu;
FPSWindow FPSDisplay;
public Main core;
private AudioData music;
public GameScreen(Polyjet polyJet, GamePlayMap gpm) {
public GameScreen(Main polyJet, GamePlayMap gpm) {
core = polyJet;
// Overlay stuff
overlay = new Stage();
scoreLabel = new Label("Score: 0", core.getDefaultSkin(), "default-font", Color.WHITE);
scoreLabel.setPosition(25, Gdx.graphics.getHeight() - scoreLabel.getHeight() - 25);
ImageButton pause = new ImageButton(core.getDefaultSkin().getDrawable("pause"),
core.getDefaultSkin().getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 25,
@ -56,65 +38,27 @@ public class GameScreen extends ScreenAdapter implements InputProcessor {
pause();
}
});
WidgetGroup healthBar = new WidgetGroup();
final Image healthBarTank = new Image(core.getDefaultSkin().getPatch("bar-empty"));
healthBarTank.setHeight(100);
healthBar.setSize(healthBarTank.getWidth(), healthBarTank.getHeight());
healthBar.setPosition(Gdx.graphics.getWidth() - healthBar.getWidth() - 16,
pause.getY() - healthBar.getHeight() - 32);
Image healthBarFiller = new Image(core.getDefaultSkin().getPatch("bar-fill")) {
@Override
public void act(float delta) {
setHeight(
((float) gameArea.getPolyjet().health / (float) gameArea.getMaxHealth()) * (healthBarTank.getHeight()));
super.act(delta);
}
};
healthBar.addActor(healthBarFiller);
healthBar.addActor(healthBarTank);
overlay.addActor(healthBar);
FPSDisplay = new FPSWindow("FPS", core.getDefaultSkin());
overlay.addActor(pause);
overlay.addActor(scoreLabel);
// Pause menu
pauseMenu = new Window("Paused", core.getDefaultSkin());
pauseMenu.add(new TextButton("resume", core.getDefaultSkin()) {
{
addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
reBegin();
}
});
}
}).space(20f);
pauseMenu.setModal(true);
pauseMenu.setPosition((Gdx.graphics.getWidth() - pauseMenu.getWidth()) / 2,
(Gdx.graphics.getHeight() - pauseMenu.getHeight()) / 2);
// Continue to add things to input multiplexer
music = gpm.getMusicData();
gameArea = new GamePlayArea(polyJet.getAssetManager(), core.getPrefs());
gameArea.setAudioMap(gpm);
gameHUD = new GameHUD(polyJet.getDefaultSkin(), gpm.getPlayableClip(), gameArea.getMaxHealth());
inputs = new InputMultiplexer();
inputs.addProcessor(this);
inputs.addProcessor(overlay);
inputs.addProcessor(gameHUD);
inputs.addProcessor(gameArea);
if (!paused) {
music.getPlaybackMusic().play();
}
}
@Override
public void show() {
Gdx.input.setInputProcessor(inputs);
gameArea.loadShaders(core.getPrefs());
if (!gameHUD.isPaused()) {
music.getPlaybackMusic().play();
}
super.show();
}
@ -122,22 +66,23 @@ public class GameScreen extends ScreenAdapter implements InputProcessor {
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
Gdx.gl.glLineWidth(1f);
gameArea.getViewport().apply();
// Gdx.gl.glLineWidth(1f);
gameArea.getViewport().apply();
gameArea.draw();
overlay.getViewport().apply();
overlay.draw();
if (!paused) {
scoreLabel.setText("Score: " + gameArea.getScore());
gameHUD.getViewport().apply();
gameHUD.draw();
if (!gameHUD.isPaused()) {
gameHUD.setScore(gameArea.getScore());
gameArea.act(delta);
if (gameArea.getPolyjet().isDead()) {
end(false);
}
overlay.act(delta);
gameHUD.act(delta);
}
if (!music.getPlaybackMusic().isPlaying()) {
@ -157,102 +102,23 @@ public class GameScreen extends ScreenAdapter implements InputProcessor {
@Override
public void dispose() {
overlay.dispose();
gameHUD.dispose();
gameArea.dispose();
super.dispose();
}
@Override
public void pause() {
gameHUD.setPaused(true);
super.pause();
}
@Override
public void resize(int width, int height) {
gameArea.getViewport().update(width, height, true);
overlay.getViewport().update(width, height, true);
gameHUD.getViewport().update(width, height, true);
super.resize(width, height);
}
@Override
public void pause() {
paused = true;
overlay.addActor(pauseMenu);
music.getPlaybackMusic().pause();
super.pause();
}
@Override
public void resume() {
super.resume();
}
public void reBegin() {
paused = false;
pauseMenu.remove();
music.getPlaybackMusic().play();
}
@Override
public boolean keyUp(int keycode) {
switch (keycode) {
case Keys.F3:
if (debug) {
debug = false;
for (int i = 0; i < gameArea.getActors().size; i++) {
gameArea.setDebugAll(debug);
}
FPSDisplay.remove();
} else {
debug = true;
for (int i = 0; i < gameArea.getActors().size; i++) {
gameArea.setDebugAll(debug);
}
overlay.addActor(FPSDisplay);
}
break;
case Keys.ESCAPE:
if (paused) {
reBegin();
} else {
pause();
}
break;
}
return false;
}
@Override
public boolean keyTyped(char character) {
return false;
}
@Override
public boolean mouseMoved(int screenX, int screenY) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean scrolled(int amount) {
return false;
}
@Override
public boolean keyDown(int keycode) {
return false;
}
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
return false;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
return false;
}
@Override
public boolean touchDragged(int screenX, int screenY, int pointer) {
return false;
}
}

View File

@ -12,17 +12,17 @@ import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.util.TransitionAdapter;
public class LoadingScreen extends ScreenAdapter {
private Stage stage;
Polyjet core;
Main core;
Image zero1HD;
Screen gotoScreen;
boolean reInit;
public LoadingScreen(Polyjet core, Screen gotoScreen, boolean reInit, boolean timer) {
public LoadingScreen(Main core, Screen gotoScreen, boolean reInit, boolean timer) {
this.core = core;
this.gotoScreen = gotoScreen;
this.reInit = reInit;

View File

@ -12,7 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.ui.pages.CreditsPage;
import zero1hd.polyjet.ui.pages.MainPage;
import zero1hd.polyjet.ui.pages.MoreOptionsPage;
@ -30,9 +30,9 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
private CreditsPage creditsPage;
private MoreOptionsPage moreOptionsPage;
private Polyjet core;
private Main core;
public MainMenu(final Polyjet core) {
public MainMenu(final Main core) {
this.core = core;
stage = new Stage(new ScreenViewport());
targetPosition = new Vector3(stage.getCamera().position);

View File

@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.Audio;
import zero1hd.polyjet.ui.pages.AnalyzePage;
import zero1hd.polyjet.ui.pages.MusicSelectionPage;
@ -23,9 +23,9 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
MusicSelectionPage ms;
AnalyzePage ap;
private Vector3 cameraPos;
private Polyjet core;
private Main core;
public PreGameScreen(Polyjet core) {
public PreGameScreen(Main core) {
stage = new Stage(new ScreenViewport());
cameraPos = new Vector3(stage.getCamera().position);
this.core = core;
@ -60,10 +60,6 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
cameraPos.x = 1.5f*Gdx.graphics.getWidth();
ap.setSong(Audio.getAudioData(ms.getSelectedMusic()), ms.getSelectedMusicInfo(), this);
break;
case SPECTRAL_FLUX_DONE:
break;
case MUSIC_DATA_CLEANED:
break;
case BACK:
if (cameraPos.x == 1.5f*Gdx.graphics.getWidth()) {
cameraPos.x = 0.5f*Gdx.graphics.getWidth();
@ -85,7 +81,7 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
ms.beginMusicSearch();
stage.addActor(ms);
ap = new AnalyzePage(core.getDefaultSkin(), core.getAssetManager());
ap = new AnalyzePage(core);
ap.miniSender.addListener(this);
ap.setPosition(Gdx.graphics.getWidth(), ap.getY());
stage.addActor(ap);

View File

@ -0,0 +1,52 @@
package zero1hd.polyjet.ui.builders;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
public class HealthBar extends WidgetGroup {
Image empty;
Image filled;
int health;
int maxHealth;
public HealthBar(Skin skin, int maxHealth) {
super();
empty = new Image(skin.getPatch("bar-empty"));
filled = new Image(skin.getPatch("bar-fill"));
addActor(empty);
addActor(filled);
this.maxHealth = maxHealth;
}
public void setHealth(int health) {
this.health = health;
filled.addAction(Actions.sizeTo(getWidth(), MathUtils.round((health/maxHealth)*getHeight()), 0.1f));;
}
@Override
public void setSize(float width, float height) {
empty.setSize(width, height);
filled.setSize(width, height);
super.setSize(width, height);
}
@Override
public void setWidth(float width) {
empty.setWidth(width);
filled.setWidth(width);
super.setWidth(width);
}
@Override
public void setHeight(float height) {
empty.setHeight(height);
super.setHeight(height);
}
}

View File

@ -1,7 +1,6 @@
package zero1hd.polyjet.ui.pages;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Interpolation;
@ -16,10 +15,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.utils.Align;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.audio.AudioData;
import zero1hd.polyjet.audio.AudioInfo;
import zero1hd.polyjet.audio.map.GamePlayMap;
import zero1hd.polyjet.audio.map.RhythmMapAlgorithm;
import zero1hd.polyjet.screens.GameScreen;
import zero1hd.polyjet.ui.builders.ScrollText;
import zero1hd.polyjet.util.MiniEvents;
import zero1hd.polyjet.util.MiniListener;
@ -53,9 +55,12 @@ public class AnalyzePage extends Page implements MiniListener {
private Thread mapGenThread;
public AnalyzePage(Skin skin, AssetManager assets) {
super("Results", skin);
this.skin = skin;
private Main core;
public AnalyzePage(Main core) {
super("Results", core.getDefaultSkin());
this.skin = core.getDefaultSkin();
this.core = core;
songInfo = new Table(skin);
songInfo.align(Align.top);
@ -149,7 +154,7 @@ public class AnalyzePage extends Page implements MiniListener {
beginTable.pack();
addActor(beginTable);
loadingCircle = new Image(assets.get("cybercircle1.png", Texture.class));
loadingCircle = new Image(core.getAssetManager().get("cybercircle1.png", Texture.class));
loadingCircle.setPosition((getWidth()-loadingCircle.getWidth())/2, (getHeightBelowTitle()-loadingCircle.getHeight())/2);
loadingCircle.setColor(0.8f,0.8f,0.8f,0.7f);
loadingCircle.setOrigin(loadingCircle.getWidth()/2, loadingCircle.getHeight()/2);
@ -267,6 +272,21 @@ public class AnalyzePage extends Page implements MiniListener {
case MAP_GENERATED:
endTime = System.currentTimeMillis();
info[5].setText("Done. Generation time: " + ((endTime - startTime)/1000f) + "s");
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
final GameScreen gameScreen = new GameScreen(core, mapGenAlgorithm.getMap());
beginButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
core.setScreen(gameScreen);
}
});
}
});
info[5].addAction(Actions.color(Color.BLACK, 0.75f));
songInfo.addAction(Actions.moveTo(songInfo.getX(), getHeightBelowTitle()-songInfo.getHeight(), 0.75f, Interpolation.linear));
difficultyTable.addAction(Actions.sequence(Actions.delay(0.4f), Actions.moveTo(songInfo.getX(), getHeightBelowTitle()-songInfo.getHeight()-difficultyTable.getHeight()-10f,0.8f, Interpolation.linear)));
@ -282,4 +302,8 @@ public class AnalyzePage extends Page implements MiniListener {
info[3].setText("finalizing data...");
info[3].addAction(Actions.color(Color.BLACK, 0.75f));
}
public GamePlayMap getMap() {
return mapGenAlgorithm.getMap();
}
}

View File

@ -13,7 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.screens.PreGameScreen;
public class MainPage extends Page {
@ -26,11 +26,11 @@ public class MainPage extends Page {
private TextButton credits;
private WidgetGroup playButton;
public MainPage(final Polyjet core, final Vector3 targetPosition) {
public MainPage(final Main core, final Vector3 targetPosition) {
polyjetTitle = new Image(core.getAssetManager().get("PolyjetTitle.png", Texture.class));
polyjetTitle.setPosition(15, getHeight() - polyjetTitle.getHeight()-15);
addActor(polyjetTitle);
polyJetVersion = new Label("Version: " + Polyjet.VERSION, core.getDefaultSkin(), "sub-font",
polyJetVersion = new Label("Version: " + Main.VERSION, core.getDefaultSkin(), "sub-font",
core.getDefaultSkin().getColor("default"));
polyJetVersion.setPosition(3, 3);
addActor(polyJetVersion);

View File

@ -7,7 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.controls.KeyMap;
import zero1hd.polyjet.ui.builders.GraphicsTable;
import zero1hd.polyjet.ui.builders.SetControls;
@ -21,7 +21,7 @@ public class MoreOptionsPage extends Page {
private GraphicsTable graphicsSettings;
public MoreOptionsPage(Polyjet core, final Vector3 targetLocation) {
public MoreOptionsPage(Main core, final Vector3 targetLocation) {
keymap = new KeyMap(core);
TextButton backArrow = new TextButton("Back", core.getDefaultSkin());

View File

@ -15,7 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.AudioInfo;
import zero1hd.polyjet.ui.builders.MusicSelectable;
import zero1hd.polyjet.ui.windows.LoadingWindow;
@ -25,7 +25,7 @@ import zero1hd.polyjet.util.MiniEvents;
public class MusicSelectionPage extends Page {
private volatile Table musicChoices;
Preferences musicFileAnnotation;
private Polyjet core;
private Main core;
private volatile ScrollPane musicChoiceScroller;
private volatile LoadingWindow loadingWindow;
@ -35,7 +35,7 @@ public class MusicSelectionPage extends Page {
private FileHandle selectedMusic;
private AudioInfo selectedMusicInfo;
public MusicSelectionPage(final Polyjet core) {
public MusicSelectionPage(final Main core) {
super("Select music", core.getDefaultSkin());
this.core = core;

View File

@ -16,7 +16,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.screens.CreativeDebugScreen;
import zero1hd.polyjet.screens.MainMenu;
@ -25,10 +25,10 @@ public class OptionsPage extends Page {
private ProgressBar musicVolSlider;
private ProgressBar fxVolSlider;
private TextField directoryField;
private Polyjet core;
private Main core;
private byte goToScreen;
public OptionsPage(final Polyjet core, final Vector3 targetPosition, final MoreOptionsPage moreOptionsPage) {
public OptionsPage(final Main core, final Vector3 targetPosition, final MoreOptionsPage moreOptionsPage) {
this.core = core;
optionsTable.defaults().spaceLeft(40f).padTop(5f).padBottom(5f).left();

View File

@ -13,7 +13,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.audio.map.RhythmMapAlgorithm;
import zero1hd.polyjet.screens.MainMenu;
@ -28,7 +28,7 @@ import zero1hd.polyjet.ui.windows.VolumeWindow;
import zero1hd.polyjet.util.MiniEvents;
import zero1hd.polyjet.util.MiniListener;
public class CreativeStage extends Stage implements MiniListener {
public class CreativeHUD extends Stage implements MiniListener {
MusicController musicPlayBackControls;
MusicSelector musicSelector;
FPSWindow fpsViewer;
@ -43,7 +43,7 @@ public class CreativeStage extends Stage implements MiniListener {
Window toolbox;
GamePlayArea gpa;
public CreativeStage(final Polyjet core, final MainMenu mainMenu, final GamePlayArea gpa) {
public CreativeHUD(final Main core, final MainMenu mainMenu, final GamePlayArea gpa) {
this.gpa = gpa;
musicSelector = new MusicSelector("Select Audio File", core.getDefaultSkin(), core.getPrefs().getString("music dir"), "default");
musicSelector.miniSender.addListener(this);

View File

@ -0,0 +1,126 @@
package zero1hd.polyjet.ui.stages;
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.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import zero1hd.polyjet.ui.builders.HealthBar;
import zero1hd.polyjet.ui.windows.FPSWindow;
import zero1hd.polyjet.ui.windows.PauseMenu;
public class GameHUD extends Stage {
private Label score;
private ImageButton pause;
private boolean paused;
private FPSWindow fpsWindow;
private PauseMenu pauseMenu;
private HealthBar healthBar;
private Music music;
public GameHUD(Skin skin, Music music, int maxHealth) {
super();
this.music = music;
score = new Label("Score: 0", skin, "default-font", Color.WHITE);
score.setPosition(10f, Gdx.graphics.getHeight()-score.getHeight() - 10f);
addActor(score);
pause = new ImageButton(skin.getDrawable("pause"),
skin.getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 15f,
Gdx.graphics.getHeight() - pause.getHeight() - 15f);
pause.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
setPaused(true);
}
});
addActor(pause);
fpsWindow = new FPSWindow("FPS", skin);
fpsWindow.setPosition(15f, 15f);
addActor(fpsWindow);
pauseMenu = new PauseMenu(skin);
pauseMenu.getResumeButton().addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
setPaused(false);
}
});
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.setHealth(maxHealth);
healthBar.setPosition(Gdx.graphics.getWidth()-healthBar.getWidth() -10f, (Gdx.graphics.getHeight()-healthBar.getHeight())/2f);
addActor(healthBar);
}
/**
* sets the label for scoring to the designated score
* @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));
}
public void setPaused(boolean paused) {
if (paused) {
addActor(pauseMenu);
music.pause();
} else {
pauseMenu.remove();
music.play();
}
this.paused = paused;
}
/**
* toggle's between the two states of paused and unpaused
* @return whatever the new game state is (true for paused)
*/
public boolean togglePause() {
if (isPaused()) {
setPaused(false);
} else {
setPaused(true);
}
return isPaused();
}
public boolean isPaused() {
return paused;
}
@Override
public boolean keyUp(int keycode) {
switch (keycode) {
case Keys.F3:
addActor(fpsWindow);
break;
case Keys.ESCAPE:
togglePause();
break;
default:
break;
}
return false;
}
}

View File

@ -12,7 +12,7 @@ import com.badlogic.gdx.graphics.glutils.ShaderProgram;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.FitViewport;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
import zero1hd.polyjet.audio.map.EntitySpawnInfo;
import zero1hd.polyjet.audio.map.GamePlayMap;
import zero1hd.polyjet.audio.map.MapWindowData;
@ -31,8 +31,10 @@ public class GamePlayArea extends Stage {
public EntityController ec;
private CollisionDetector collisionDetector;
private float maxHealth = 100;
private float yTeleport = Polyjet.GAME_AREA_HEIGHT/2;
private int maxHealth = 100;
private float yTeleport = Main.GAME_AREA_HEIGHT/2;
private int score;
private ShaderProgram glowShader;
@ -42,11 +44,8 @@ public class GamePlayArea extends Stage {
private ShaderProgram bgShader;
private Texture background;
private float time;
public GamePlayArea(AssetManager assetManager, Preferences prefs) {
super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT));
super(new FitViewport(Main.GAME_AREA_WIDTH, Main.GAME_AREA_HEIGHT));
Gdx.app.debug("Game Area", "new area created");
background = assetManager.get("star_bg.png");
@ -58,10 +57,8 @@ public class GamePlayArea extends Stage {
}
public void setAudioMap(GamePlayMap audioMap) {
time = 0;
this.audioMap = audioMap;
}
/**
* needs to be called right after set as screen (should be called in show method).
* @param prefs
@ -74,7 +71,7 @@ public class GamePlayArea extends Stage {
System.err.println(glowShader.getLog());
System.exit(0);
}
if (glowShader.getLog().length()!=0) {
if (glowShader.getLog().length() != 0) {
System.out.println(glowShader.getLog());
}
@ -120,10 +117,13 @@ public class GamePlayArea extends Stage {
if (bgShader != null) {
getBatch().setShader(bgShader);
bgShader.setUniformf("time", time);
bgShader.setUniformf("resolution", background.getWidth(), background.getHeight());
if (audioMap != null) {
bgShader.setUniformf("time", audioMap.getPlayableClip().getPosition());
}
}
getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
getBatch().draw(background, 0f, 0f, Main.GAME_AREA_WIDTH, Main.GAME_AREA_HEIGHT);
getBatch().end();
getBatch().setShader(null);
@ -144,7 +144,7 @@ public class GamePlayArea extends Stage {
getBatch().setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
getBatch().begin();
getBatch().setShader(glowShader);
getBatch().draw(fboRegion, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
getBatch().draw(fboRegion, 0f, 0f, Main.GAME_AREA_WIDTH, Main.GAME_AREA_HEIGHT);
getBatch().setShader(null);
getBatch().end();
@ -158,7 +158,6 @@ public class GamePlayArea extends Stage {
MapWindowData mwd;
if (audioMap != null && audioMap.getPlayableClip().isPlaying()) {
audioMap.getMusicData().readIndexUpdate();
time = audioMap.getPlayableClip().getPosition();
if ((mwd = audioMap.nextWindowData()) != null) {
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
if (currentSpawnInfo != null) {
@ -177,14 +176,14 @@ public class GamePlayArea extends Stage {
polyjet.setX(1f);
}
if (polyjet.getX() >= Polyjet.GAME_AREA_WIDTH-1-polyjet.getWidth()) {
if (polyjet.getX() >= Main.GAME_AREA_WIDTH-1-polyjet.getWidth()) {
polyjet.moveRight = false;
polyjet.setX(Polyjet.GAME_AREA_WIDTH-1f-polyjet.getWidth());
polyjet.setX(Main.GAME_AREA_WIDTH-1f-polyjet.getWidth());
}
if (polyjet.getY() >= Polyjet.GAME_AREA_HEIGHT - 1 - polyjet.getHeight()) {
if (polyjet.getY() >= Main.GAME_AREA_HEIGHT - 1 - polyjet.getHeight()) {
polyjet.moveUp = false;
polyjet.setY(Polyjet.GAME_AREA_HEIGHT - 1 - polyjet.getHeight());
polyjet.setY(Main.GAME_AREA_HEIGHT - 1 - polyjet.getHeight());
}
if (polyjet.getY() <= 1) {
@ -260,7 +259,7 @@ public class GamePlayArea extends Stage {
return score;
}
public float getMaxHealth() {
public int getMaxHealth() {
return maxHealth;
}
public float getyTeleport() {

View File

@ -0,0 +1,31 @@
package zero1hd.polyjet.ui.windows;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Window;
public class PauseMenu extends Window {
private Label label;
private TextButton resumeButton;
public PauseMenu(Skin skin) {
super("Paused", skin, "tinted");
defaults().pad(35f);
label = new Label("Game is paused.", skin);
add(label).spaceBottom(20f);
row();
resumeButton = new TextButton("Resume", skin);
add(resumeButton);
pack();
setModal(true);
}
public TextButton getResumeButton() {
return resumeButton;
}
}

View File

@ -3,7 +3,7 @@ package zero1hd.polyjet.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.Main;
public class DesktopLauncher {
public static void main (String[] arg) {
@ -15,7 +15,7 @@ public class DesktopLauncher {
// System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
new LwjglApplication(new Polyjet(), config);
new LwjglApplication(new Main(), config);
}
}