fixed minor resize bug on pre game screen and made small design changes to entities

This commit is contained in:
Harrison Deng 2017-07-12 16:01:13 -05:00
parent 2cd752f25c
commit 44551bdea3
5 changed files with 57 additions and 12 deletions

View File

@ -78,11 +78,12 @@ public class RhythmMapAlgorithm implements Runnable {
map.addNullToMap(); map.addNullToMap();
} }
progress = (int) (100f*index/bassPeaks.size); progress = MathUtils.round(100f*index/bassPeaks.size);
sender.send(MiniEvents.MAPGEN_ITERATED); sender.send(MiniEvents.MAPGEN_ITERATED);
} }
map.endBuild(); map.endBuild();
sender.send(MiniEvents.MAP_GENERATED);
} }
public synchronized GamePlayMap getMap() { public synchronized GamePlayMap getMap() {

View File

@ -1,5 +1,6 @@
package zero1hd.polyjet.entity.enemies; package zero1hd.polyjet.entity.enemies;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.MathUtils;
@ -16,6 +17,7 @@ public class Flake extends Actor implements Poolable, Entity {
private Texture texture; private Texture texture;
private float rate; private float rate;
private float timer; private float timer;
private float totalTime;
private Shard[] shards; private Shard[] shards;
private Rectangle hitbox; private Rectangle hitbox;
private Vector2 center; private Vector2 center;
@ -33,6 +35,7 @@ public class Flake extends Actor implements Poolable, Entity {
setSize(3f, 3f); setSize(3f, 3f);
this.rate = rate; this.rate = rate;
this.timer = fuse; this.timer = fuse;
this.totalTime = fuse;
hitbox.setSize(getWidth(), getHeight()); hitbox.setSize(getWidth(), getHeight());
center.set(getWidth()/2f, getHeight()/2f); center.set(getWidth()/2f, getHeight()/2f);
setPosition(x-center.x, y-center.y); setPosition(x-center.x, y-center.y);
@ -59,12 +62,21 @@ public class Flake extends Actor implements Poolable, Entity {
@Override @Override
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
batch.setColor(0.25f,0.25f,0.25f,1f- timer/totalTime);
batch.draw(texture, getX(), getY(), getWidth(), getHeight()); batch.draw(texture, getX(), getY(), getWidth(), getHeight());
batch.setColor(Color.WHITE);
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);
} }
@Override @Override
public void collided(Entity entity) { public void collided(Entity entity) {
switch (entity.getEntityType()) {
case LASER:
timer --;
break;
default:
break;
}
} }
@Override @Override
@ -99,6 +111,7 @@ public class Flake extends Actor implements Poolable, Entity {
setSize(0, 0); setSize(0, 0);
center.set(0, 0); center.set(0, 0);
rot.set(0, 0); rot.set(0, 0);
totalTime = 0;
} }
} }

View File

@ -71,7 +71,7 @@ public class Shard extends Actor implements Entity, Poolable {
@Override @Override
public void draw(Batch batch, float parentAlpha) { public void draw(Batch batch, float parentAlpha) {
sprite.setCenter(getX()+center.x, getY()+center.y); sprite.setCenter(getX()+center.x, getY()+center.y);
sprite.setColor(1.3f-((float)hp/(float)maxHp), 1.3f-((float)hp/(float)maxHp), 1.3f-((float)hp/(float)maxHp), 0.75f); sprite.setColor(((float)hp/(float)maxHp), ((float)hp/(float)maxHp), ((float)hp/(float)maxHp), 0.5f);
sprite.draw(batch); sprite.draw(batch);
batch.setColor(Color.WHITE); batch.setColor(Color.WHITE);
super.draw(batch, parentAlpha); super.draw(batch, parentAlpha);

View File

@ -78,6 +78,8 @@ public class PreGameScreen extends ScreenAdapter implements TransitionAdapter, M
@Override @Override
public Screen postTransition() { public Screen postTransition() {
stage.clear();
ms = new MusicSelectionPage(core); ms = new MusicSelectionPage(core);
ms.miniSender.addListener(this); ms.miniSender.addListener(this);
ms.beginMusicSearch(); ms.beginMusicSearch();

View File

@ -29,6 +29,9 @@ public class AnalyzePage extends Page implements MiniListener {
AudioData music; AudioData music;
RhythmMapAlgorithm mapGenAlgorithm; RhythmMapAlgorithm mapGenAlgorithm;
private Table songInfo;
private volatile Label[] info;
Table difficultyTable; Table difficultyTable;
private Label diffTitle; private Label diffTitle;
private Slider sensitivityRating; private Slider sensitivityRating;
@ -41,18 +44,25 @@ public class AnalyzePage extends Page implements MiniListener {
private boolean confirmed; private boolean confirmed;
private Skin skin; private Skin skin;
private Table beginTable;
private TextButton beginButton;
private TextButton back; private TextButton back;
private Image loadingCircle; private Image loadingCircle;
private long startTime, endTime; private long startTime, endTime;
Table songInfo;
private Label[] info;
private Thread mapGenThread; private Thread mapGenThread;
public AnalyzePage(Skin skin, AssetManager assets) { public AnalyzePage(Skin skin, AssetManager assets) {
super("Results", skin); super("Results", skin);
this.skin = skin; this.skin = skin;
songInfo = new Table(skin);
songInfo.align(Align.top);
songInfo.pad(15f);
songInfo.setBackground(skin.getDrawable("large-pane"));
addActor(songInfo);
difficultyTable = new Table(skin); difficultyTable = new Table(skin);
difficultyTable.setBackground(skin.getDrawable("large-pane")); difficultyTable.setBackground(skin.getDrawable("large-pane"));
addActor(difficultyTable); addActor(difficultyTable);
@ -118,6 +128,10 @@ public class AnalyzePage extends Page implements MiniListener {
info[2].setText("Confirmed."); info[2].setText("Confirmed.");
confirmed = true; confirmed = true;
confirmDiffButton.setDisabled(true); confirmDiffButton.setDisabled(true);
sensitivityRating.setDisabled(true);
speedModifier.setDisabled(true);
healthModifier.setDisabled(true);
if (audioAnalyzer.containsData() ) { if (audioAnalyzer.containsData() ) {
finalizeData(); finalizeData();
} }
@ -127,9 +141,13 @@ public class AnalyzePage extends Page implements MiniListener {
difficultyTable.pack(); difficultyTable.pack();
songInfo = new Table(skin); beginTable = new Table(skin);
songInfo.setBackground(skin.getDrawable("large-pane")); beginTable.pad(15f);
addActor(songInfo); beginButton = new TextButton("Begin!", skin);
beginTable.add(beginButton);
beginTable.setBackground(skin.getDrawable("large-pane"));
beginTable.pack();
addActor(beginTable);
loadingCircle = new Image(assets.get("cybercircle1.png", Texture.class)); loadingCircle = new Image(assets.get("cybercircle1.png", Texture.class));
loadingCircle.setPosition((getWidth()-loadingCircle.getWidth())/2, (getHeightBelowTitle()-loadingCircle.getHeight())/2); loadingCircle.setPosition((getWidth()-loadingCircle.getWidth())/2, (getHeightBelowTitle()-loadingCircle.getHeight())/2);
@ -145,8 +163,10 @@ public class AnalyzePage extends Page implements MiniListener {
@Override @Override
public void changed(ChangeEvent event, Actor actor) { public void changed(ChangeEvent event, Actor actor) {
miniSender.send(MiniEvents.BACK); miniSender.send(MiniEvents.BACK);
if (audioAnalyzer != null) {
audioAnalyzer.stop(); audioAnalyzer.stop();
} }
}
}); });
info = new Label[6]; info = new Label[6];
@ -158,9 +178,13 @@ public class AnalyzePage extends Page implements MiniListener {
} }
public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) { public void setSong(AudioData music, AudioInfo audioInfo, MiniListener listener) {
confirmed = false;
confirmDiffButton.setDisabled(false);
sensitivityRating.setDisabled(false);
speedModifier.setDisabled(false);
healthModifier.setDisabled(false);
songInfo.clear(); songInfo.clear();
songInfo.align(Align.top);
songInfo.pad(15f);
songInfo.defaults().align(Align.left | Align.top); songInfo.defaults().align(Align.left | Align.top);
audioAnalyzer = new AudioAnalyzer(); audioAnalyzer = new AudioAnalyzer();
audioAnalyzer.sender.addListener(this); audioAnalyzer.sender.addListener(this);
@ -182,6 +206,8 @@ public class AnalyzePage extends Page implements MiniListener {
songInfo.setPosition((getWidth()-songInfo.getWidth())/2f, (getHeightBelowTitle()-songInfo.getHeight())/2f); songInfo.setPosition((getWidth()-songInfo.getWidth())/2f, (getHeightBelowTitle()-songInfo.getHeight())/2f);
difficultyTable.setPosition(songInfo.getX(), -difficultyTable.getHeight()); difficultyTable.setPosition(songInfo.getX(), -difficultyTable.getHeight());
difficultyTable.setWidth(songInfo.getWidth()); difficultyTable.setWidth(songInfo.getWidth());
beginTable.setPosition(difficultyTable.getX(), -beginTable.getHeight());
beginTable.setWidth(difficultyTable.getWidth());
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
info[0].addAction(Actions.color(Color.BLACK, 2.5f)); info[0].addAction(Actions.color(Color.BLACK, 2.5f));
@ -236,12 +262,15 @@ public class AnalyzePage extends Page implements MiniListener {
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
break; break;
case MAPGEN_ITERATED: case MAPGEN_ITERATED:
info[4].setText("Generating map: " + mapGenAlgorithm.getProgress()); info[4].setText("Generating map: " + mapGenAlgorithm.getProgress() + "%");
break; break;
case MAP_GENERATED: case MAP_GENERATED:
endTime = System.currentTimeMillis(); endTime = System.currentTimeMillis();
info[5].setText("Done. Generation time: " + ((endTime - startTime)/1000f) + "s"); info[5].setText("Done. Generation time: " + ((endTime - startTime)/1000f) + "s");
info[5].addAction(Actions.color(Color.BLACK, 0.75f)); 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)));
beginTable.addAction(Actions.sequence(Actions.delay(0.5f), Actions.moveTo(difficultyTable.getX(), getHeightBelowTitle()-songInfo.getHeight()-difficultyTable.getHeight()-beginTable.getHeight()-20f,0.8f, Interpolation.linear)));
default: default:
break; break;
} }