Initial commit

This commit is contained in:
2017-04-18 18:25:45 -05:00
commit fa87f5e8cf
176 changed files with 7413 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.ui.stages.CreativeStage;
import zero1hd.polyjet.ui.stages.GamePlayArea;
public class CreativeDebugScreen extends ScreenAdapter {
CreativeStage creative;
GamePlayArea gamePlayArea;
InputMultiplexer inputs;
public CreativeDebugScreen(Polyjet core) {
creative = new CreativeStage(core);
gamePlayArea = new GamePlayArea(core);
inputs = new InputMultiplexer(creative, gamePlayArea);
}
@Override
public void show() {
Gdx.input.setInputProcessor(inputs);
super.show();
}
@Override
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);
gamePlayArea.getViewport().apply();
gamePlayArea.act();
gamePlayArea.draw();
creative.getViewport().apply();
creative.act();
creative.draw();
super.render(delta);
}
@Override
public void resize(int width, int height) {
// TODO Auto-generated method stub
super.resize(width, height);
}
}

View File

@@ -0,0 +1,260 @@
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.audio.AudioData;
import zero1hd.polyjet.maps.RhythmMap;
import zero1hd.polyjet.ui.stages.GamePlayArea;
import zero1hd.polyjet.ui.windows.FPSWindow;
public class GameScreen extends ScreenAdapter implements InputProcessor {
private GamePlayArea gameArea;
public InputMultiplexer inputs;
public boolean paused = false;
private boolean debug = false;
public Polyjet core;
public Stage overlay;
private Label scoreLabel;
Window pauseMenu;
FPSWindow FPSDisplay;
private AudioData music;
public GameScreen(Polyjet polyJet) {
core = polyJet;
// Overlay stuff
overlay = new Stage();
scoreLabel = new Label("Score: 0", core.defaultSkin, "default-font", Color.WHITE);
scoreLabel.setPosition(25, Gdx.graphics.getHeight() - scoreLabel.getHeight() - 25);
ImageButton pause = new ImageButton(core.defaultSkin.getDrawable("pause"),
core.defaultSkin.getDrawable("pause-down"));
pause.setPosition(Gdx.graphics.getWidth() - pause.getWidth() - 25,
Gdx.graphics.getHeight() - pause.getHeight() - 25);
pause.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
pause();
}
});
WidgetGroup healthBar = new WidgetGroup();
final Image healthBarTank = new Image(core.defaultSkin.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.defaultSkin.getPatch("bar-fill")) {
@Override
public void act(float delta) {
setHeight(
((float) gameArea.getHealth() / (float) gameArea.getMaxHealth()) * (healthBarTank.getHeight()));
super.act(delta);
}
};
healthBar.addActor(healthBarFiller);
healthBar.addActor(healthBarTank);
overlay.addActor(healthBar);
FPSDisplay = new FPSWindow("FPS", core.defaultSkin);
overlay.addActor(pause);
overlay.addActor(scoreLabel);
// Pause menu
pauseMenu = new Window("Paused", core.defaultSkin);
pauseMenu.add(new TextButton("resume", core.defaultSkin) {
{
addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
recommence();
}
});
}
}).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
gameArea = new GamePlayArea(core);
inputs = new InputMultiplexer();
inputs.addProcessor(this);
inputs.addProcessor(overlay);
inputs.addProcessor(gameArea);
if (!paused) {
music.getPlaybackMusic().play();
}
}
public void setMap (RhythmMap map) {
this.music = map.analyzer.audiofile;
gameArea.setMap(map);
}
@Override
public void show() {
Gdx.input.setInputProcessor(inputs);
super.show();
}
@Override
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);
gameArea.getViewport().apply();
gameArea.draw();
overlay.getViewport().apply();
overlay.draw();
if (!paused) {
music.readIndexUpdate();
gameArea.setAudioIndex(music.getReadIndex());
scoreLabel.setText("Score: " + gameArea.getScore());
gameArea.act(delta);
if (gameArea.getHealth() == 0) {
end(false);
}
overlay.act(delta);
} else {
}
if (!music.getPlaybackMusic().isPlaying()) {
end(true);
}
}
private void end(boolean trueEnd) {
if (trueEnd) {
// TODO they didn't die
} else {
// TODO They done goofed and ended up dying.
}
}
@Override
public void dispose() {
overlay.dispose();
gameArea.dispose();
super.dispose();
}
@Override
public void resize(int width, int height) {
gameArea.getViewport().update(width, height, true);
overlay.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 recommence() {
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) {
recommence();
} 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

@@ -0,0 +1,77 @@
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.scenes.scene2d.Stage;
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.TransitionAdapter;
public class LoadingScreen extends ScreenAdapter {
private Stage stage;
Polyjet core;
Image zero1HD;
Screen gotoScreen;
boolean reInit;
public LoadingScreen(Polyjet core, Screen gotoScreen, boolean reInit, boolean timer) {
this.core = core;
this.gotoScreen = gotoScreen;
this.reInit = reInit;
stage = new Stage(new ScreenViewport());
core.assetManager.load("splashlogo.png", Texture.class);
core.assetManager.finishLoading();
zero1HD = new Image(this.core.assetManager.get("splashlogo.png", Texture.class));
zero1HD.setColor(0f,1f,1f,0f);
stage.addActor(zero1HD);
zero1HD.setPosition(stage.getWidth()/2 - zero1HD.getWidth()/2, stage.getHeight()/2 - zero1HD.getHeight()/2);
if (timer) {
zero1HD.addAction(Actions.sequence(Actions.color(Color.WHITE, 1f)));
}
core.queueAssets();
}
float count = 0;
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(delta);
if (!zero1HD.hasActions() & core.assetManager.update()) {
Gdx.app.debug("Loading Screen", "queue has all been loaded. Action is done playing.");
zero1HD.remove();
core.generateFonts();
core.defineSkinStyles();
if (reInit) {
((TransitionAdapter) gotoScreen).postTransition();
}
core.setScreen(gotoScreen);
core.assetManager.unload("splashlogo.png");
core.assetManager.get("standard_thrust.p", ParticleEffect.class).flipY();
}
stage.draw();
super.render(delta);
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, true);
super.resize(width, height);
}
}

View File

@@ -0,0 +1,122 @@
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
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.TransitionAdapter;
import zero1hd.polyjet.ui.CreditsPage;
import zero1hd.polyjet.ui.MainPage;
import zero1hd.polyjet.ui.MoreOptionsPage;
import zero1hd.polyjet.ui.OptionsPage;
public class MainMenu extends ScreenAdapter implements TransitionAdapter {
public Stage stage;
private Vector3 targetPosition;
private MainPage mainPage;
private OptionsPage optionsPage;
private CreditsPage creditsPage;
private MoreOptionsPage moreOptionsPage;
Polyjet core;
public MainMenu(final Polyjet core) {
this.core = core;
stage = new Stage(new ScreenViewport());
targetPosition = new Vector3(stage.getCamera().position);
}
public void postTransition() {
stage.clear();
mainPage = new MainPage(core, targetPosition);
mainPage.setPosition(0, 0);
stage.addActor(mainPage);
//End main menu
moreOptionsPage = new MoreOptionsPage(core, targetPosition);
optionsPage = new OptionsPage(core, targetPosition, moreOptionsPage);
optionsPage.setPosition(Gdx.graphics.getWidth(), 0);
stage.addActor(optionsPage);
creditsPage = new CreditsPage(core.defaultSkin);
creditsPage.setPosition(0, Gdx.graphics.getHeight());
stage.addActor(creditsPage);
moreOptionsPage.setPosition(1f*Gdx.graphics.getWidth(), -1f*Gdx.graphics.getHeight());
stage.addActor(moreOptionsPage);
stage.addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Keys.ESCAPE) {
stage.unfocusAll();
if (targetPosition.x != 0.5f*Gdx.graphics.getWidth() || targetPosition.y != 0.5f*Gdx.graphics.getHeight()) {
targetPosition.x = 0.5f*Gdx.graphics.getWidth();
targetPosition.y = 0.5f*Gdx.graphics.getHeight();
}
moreOptionsPage.controlUnselect();
optionsPage.saveOptions(core.prefs);
}
return super.keyUp(event, keycode);
}
});
stage.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (stage.hit(x, y, true) == null) {
stage.unfocusAll();
moreOptionsPage.controlUnselect();
}
super.clicked(event, x, y);
}
});
Gdx.app.debug("Post Transition", "Beginning screen setup for Mainmenu.");
}
@Override
public void show() {
Gdx.input.setInputProcessor(stage);
super.show();
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act();
stage.draw();
if (stage.getCamera().position.x != targetPosition.x || stage.getCamera().position.y != targetPosition.y) {
stage.getCamera().position.lerp(targetPosition, 0.25f);
}
super.render(delta);
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height, false);
targetPosition.x = width/2;
targetPosition.y = height/2;
super.resize(width, height);
}
@Override
public void dispose() {
stage.dispose();
super.dispose();
}
}

View File

@@ -0,0 +1,158 @@
package zero1hd.polyjet.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import zero1hd.polyjet.Polyjet;
import zero1hd.polyjet.TransitionAdapter;
import zero1hd.polyjet.audio.AudioAnalyzer;
import zero1hd.polyjet.audio.WavAudioData;
import zero1hd.polyjet.maps.RhythmMap;
public class PreGameScreen extends ScreenAdapter implements TransitionAdapter {
byte phase = 0;
Polyjet core;
Stage stage;
Label statusText;
AudioAnalyzer analyzer;
WavAudioData audiofile;
RhythmMap rhythmMap;
Vector3 cameraTarget;
Label lastStatement;
public PreGameScreen(final Polyjet core) {
this.core = core;
analyzer = new AudioAnalyzer();
rhythmMap = new RhythmMap(analyzer);
stage = new Stage();
stage.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (phase == 4) {
if (core.gameScreen != null) {
core.setScreen(core.gameScreen);
} else {
core.setScreen((core.gameScreen = new GameScreen(core)));
}
}
super.clicked(event, x, y);
}
});
cameraTarget = new Vector3(stage.getCamera().position);
postTransition();
}
@Override
public void postTransition() {
stage.clear();
//draw music selector
statusText = new Label(null, core.defaultSkin);
statusText.setPosition(1.6f*Gdx.graphics.getWidth(), (Gdx.graphics.getHeight()-statusText.getHeight())/2);
Image cyberCircle1 = new Image(core.assetManager.get("cybercircle3B.png", Texture.class));
cyberCircle1.setScale(0.7f);
cyberCircle1.setOrigin(cyberCircle1.getWidth()/2, cyberCircle1.getHeight()/2);
cyberCircle1.setColor(0.8f,0.8f,0.8f,0.7f);
cyberCircle1.addAction(Actions.forever(Actions.rotateBy(-360f, 10f)));
cyberCircle1.setPosition(Gdx.graphics.getWidth()-cyberCircle1.getWidth()/2-10, -cyberCircle1.getHeight()*2/4f);
stage.addActor(cyberCircle1);
Image cyberCircle2 = new Image(core.assetManager.get("cybercircle1.png", Texture.class));
cyberCircle2.setPosition(1.5f*Gdx.graphics.getWidth()-cyberCircle2.getWidth()/2+20, (Gdx.graphics.getHeight()-cyberCircle2.getHeight())/2);
cyberCircle2.setColor(0.8f,0.8f,0.8f,0.7f);
cyberCircle2.addAction(Actions.alpha(0.7f));
stage.addActor(cyberCircle2);
stage.addActor(statusText);
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.getViewport().apply();
stage.act();
stage.draw();
switch (phase) {
case 0:
break;
case 1:
if (stage.getCamera().position.x != cameraTarget.x) {
stage.getCamera().position.lerp(cameraTarget, 0.25f);
}
if (analyzer.containsData()) {
phase++;
statusText.setText("Mapping beats");
//TODO MAP GENERATION
}
break;
case 2:
//finish map generation
if (true) {
statusText.setText("Loading assets");
statusText.setPosition(1.5f*Gdx.graphics.getWidth(), (Gdx.graphics.getHeight()-statusText.getHeight())/2);
//list of assets needed for game screen exclusively
Gdx.app.debug("PreGameScreen Phase", String.valueOf(phase));
phase++;
}
break;
case 3:
//Resource loading...
if (core.assetManager.update()) {
Gdx.app.debug("PreGameScreen Phase", String.valueOf(phase));
phase++;
Gdx.app.debug("PreGameScreen Phase", String.valueOf(phase));
cameraTarget.x = 2.5f*Gdx.graphics.getWidth();
}
break;
case 4:
if (stage.getCamera().position.x != cameraTarget.x) {
stage.getCamera().position.lerp(cameraTarget, 0.25f);
}
if (lastStatement == null) {
lastStatement = new Label("Are you ready?", core.defaultSkin);
lastStatement.setPosition(2.5f*Gdx.graphics.getWidth()-lastStatement.getWidth()/2, (Gdx.graphics.getHeight()-lastStatement.getHeight())/2);
stage.addActor(lastStatement);
}
break;
}
super.render(delta);
}
@Override
public void show() {
Gdx.input.setInputProcessor(stage);
analyzer.resetVars();
super.show();
}
@Override
public void resize(int width, int height) {
stage.getViewport().update(width, height);
super.resize(width, height);
}
@Override
public void dispose() {
stage.dispose();
super.dispose();
}
}