glasshouse/src/Game.hx

44 lines
828 B
Haxe

import Const;
@:publicFields
class Game extends hxd.App {
public var scene : h2d.Scene;
public var font : h2d.Font;
public var world : World;
public var curDialog : h2d.Object;
override function init() {
scene = s2d;
s2d.setFixedSize(Const.W, Const.H + 12);
world = new World(Res.map, Res.tiles);
s2d.add(world.root, 0);
font = Res.minecraftia_regular_6.toFont();
dialog([
"(you slowly wake up)",
"...",
"where am I?",
"(the cold vastness of spaaaaace)"
]);
}
public static var inst : Game;
function dialog( t : Array<String> ) {
if( t.length == 0 ) {
return;
}
var d = new Dialogue(Const.W, 100, t[0]);
d.y = Const.H - d.height;
d.onClick = function() {
d.remove();
curDialog = null;
var t2 = t.copy();
t2.shift();
dialog(t2);
};
curDialog = d;
}
}