You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.2 KiB
67 lines
1.2 KiB
package mightypork.rogue.screens.gamescreen;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.Random;
|
|
|
|
import mightypork.gamecore.control.AppAccess;
|
|
import mightypork.gamecore.gui.screens.LayeredScreen;
|
|
import mightypork.rogue.Paths;
|
|
import mightypork.rogue.world.MapGenerator;
|
|
import mightypork.rogue.world.World;
|
|
import mightypork.util.ion.Ion;
|
|
|
|
|
|
public class ScreenGame extends LayeredScreen {
|
|
|
|
public ScreenGame(AppAccess app) {
|
|
super(app);
|
|
|
|
addLayer(new WorldLayer(this, obtainWorld())); //TODO with provided world
|
|
addLayer(new HudLayer(this));
|
|
}
|
|
|
|
|
|
private World obtainWorld()
|
|
{
|
|
|
|
// FIXME just temporary test here
|
|
|
|
final Random rand = new Random();
|
|
final File f = new File(Paths.WORKDIR, "test-world.ion");
|
|
|
|
// SAVE
|
|
|
|
World world = MapGenerator.createWorld(rand.nextLong());
|
|
addChildClient(world);
|
|
|
|
try {
|
|
Ion.toFile(f, world);
|
|
} catch (final IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
// LOAD
|
|
|
|
// final World w;
|
|
//
|
|
// try {
|
|
// world = Ion.fromFile(f, World.class);
|
|
// } catch (IOException e) {
|
|
// e.printStackTrace();
|
|
// System.exit(1);
|
|
// return;
|
|
// }
|
|
|
|
return world;
|
|
}
|
|
|
|
|
|
@Override
|
|
public String getName()
|
|
{
|
|
return "game_screen";
|
|
}
|
|
|
|
}
|
|
|