59 lines
1.3 KiB
Java
59 lines
1.3 KiB
Java
package shootergame.menu;
|
|
|
|
import java.util.Random;
|
|
|
|
import shootergame.Main;
|
|
import shootergame.entity.player.EntityPlayer;
|
|
import shootergame.init.Layers;
|
|
import shootergame.text.Text;
|
|
import shootergame.time.GameTimer;
|
|
import shootergame.util.gl.GlHelpers;
|
|
import shootergame.util.math.vec.Vec2d;
|
|
|
|
class MenuRespawn
|
|
{
|
|
private int reset_progress = 0;
|
|
private static final Random rand = new Random();
|
|
|
|
void update(boolean resetting)
|
|
{
|
|
if(resetting) {
|
|
this.reset_progress += 10;
|
|
} else if(this.reset_progress > 0) {
|
|
this.reset_progress -= 5;
|
|
}
|
|
|
|
if(this.reset_progress >= 1000)
|
|
{
|
|
// Reset the world and the player
|
|
Layers.init(rand.nextLong());
|
|
Main.player = new EntityPlayer();
|
|
Main.menu = new MenuGame();
|
|
Main.game_paused = false;
|
|
GameTimer.resetTime();
|
|
}
|
|
}
|
|
|
|
void render()
|
|
{
|
|
GlHelpers.pushMatrix();
|
|
GlHelpers.translate2(0, 2.5);
|
|
Text.renderCenter("Press and hold fire to respawn", new Vec2d(0.5, 0.5));
|
|
GlHelpers.popMatrix();
|
|
|
|
double p = reset_progress/1000.0*8;
|
|
GlHelpers.disableTexture2d();
|
|
GlHelpers.color4(1, 1, 0, 1);
|
|
GlHelpers.begin();
|
|
{
|
|
GlHelpers.vertex2(-4.0, -3.2);
|
|
GlHelpers.vertex2(-4+p, -3.2);
|
|
GlHelpers.vertex2(-4+p, -3.0);
|
|
GlHelpers.vertex2(-4.0, -3.0);
|
|
}
|
|
GlHelpers.end();
|
|
GlHelpers.color3(0, 0, 0);
|
|
GlHelpers.enableTexture2d();
|
|
}
|
|
}
|