diff --git a/res/minecraftia_regular_6.fnt b/res/minecraftia_regular_6.fnt
new file mode 100644
index 0000000..43f089d
--- /dev/null
+++ b/res/minecraftia_regular_6.fnt
@@ -0,0 +1,195 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/minecraftia_regular_6.png b/res/minecraftia_regular_6.png
new file mode 100644
index 0000000..5628a9b
Binary files /dev/null and b/res/minecraftia_regular_6.png differ
diff --git a/res/ui.png b/res/ui.png
new file mode 100644
index 0000000..57a41c5
Binary files /dev/null and b/res/ui.png differ
diff --git a/src/Dialogue.hx b/src/Dialogue.hx
new file mode 100644
index 0000000..1e00a52
--- /dev/null
+++ b/src/Dialogue.hx
@@ -0,0 +1,94 @@
+class Dialogue extends h2d.Object {
+
+ var game : Game;
+ var bg : h2d.ScaleGrid;
+ var tf : h2d.Text;
+ var timer : haxe.Timer;
+ var int : h2d.Interactive;
+ public var width(default, set) : Int;
+ public var height(default, set) : Int;
+ public var text(default, set) : String;
+ var textPos : Int = 0;
+ var chan : hxd.snd.Channel;
+
+ // public function new(width:Int, height:Int, text : String,sfx:hxd.res.Sound) {
+ public function new(width:Int, height:Int, text : String) {
+ super();
+ // if( sfx != null )
+ // chan = sfx.play(true);
+ if( text == null ) text = "NULL";
+ game = Game.inst;
+ game.scene.add(this, 1);
+ bg = new h2d.ScaleGrid(Res.ui.toTile(), 5, 5, this);
+ bg.colorKey = 0xFF00FF;
+ tf = new h2d.Text(game.font, this);
+ tf.scaleX = 2;
+ tf.scaleY = 2;
+ tf.y = 5;
+ tf.x = 7;
+ tf.dropShadow = { dx : 0, dy : 1, color : 0, alpha : 0.3 };
+ int = new h2d.Interactive(0,0,this);
+ int.onClick = function(_) click();
+ this.width = width;
+ this.height = height;
+ this.text = text;
+ }
+
+ override function onRemove() {
+ super.onRemove();
+ if( chan != null )
+ chan.stop();
+ timer.stop();
+ }
+
+ function updateText() {
+ if( textPos == text.length ) {
+ timer.stop();
+ onReady();
+ if( chan != null ) chan.stop();
+ return;
+ }
+ if( chan != null ) {
+ switch( text.charCodeAt(textPos) ) {
+ case " ".code, "\n".code: chan.volume = 0;
+ default: if( chan.volume == 0 ) chan.volume = 1 else chan.volume *= 0.9;
+ }
+ }
+ textPos++;
+ tf.text = text.substr(0, textPos);
+ }
+
+ public function click() {
+ if( textPos == text.length ) onClick() else if( textPos < text.length ) { textPos = text.length; tf.text = text; updateText(); };
+ }
+
+ public dynamic function onClick() {
+ }
+
+ public dynamic function onReady() {
+ }
+
+ function set_text(t) {
+ text = t;
+ timer = new haxe.Timer(30);
+ timer.run = updateText;
+ tf.text = "";
+ textPos = 0;
+ return t;
+ }
+
+ function set_width(w:Int) {
+ bg.width = w;
+ int.width = w;
+ tf.maxWidth = w - 14;
+ tf.text = text;
+ return width = w;
+ }
+
+ function set_height(h:Int) {
+ bg.height = h;
+ int.height = h;
+ return height = h;
+ }
+
+}
diff --git a/src/Game.hx b/src/Game.hx
index 6a1ef92..0d81143 100644
--- a/src/Game.hx
+++ b/src/Game.hx
@@ -5,13 +5,39 @@ 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 ) {
+ 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;
+ }
+
}