diff --git a/res/map.tmx b/res/map.tmx
new file mode 100644
index 0000000..54719f0
--- /dev/null
+++ b/res/map.tmx
@@ -0,0 +1,26 @@
+
+
diff --git a/res/tiles.png b/res/tiles.png
new file mode 100644
index 0000000..daf5c70
Binary files /dev/null and b/res/tiles.png differ
diff --git a/src/Const.hx b/src/Const.hx
new file mode 100644
index 0000000..4816efe
--- /dev/null
+++ b/src/Const.hx
@@ -0,0 +1,6 @@
+class Const {
+
+ public static inline var W = 960;
+ public static inline var H = 640;
+
+}
diff --git a/src/Game.hx b/src/Game.hx
new file mode 100644
index 0000000..6a1ef92
--- /dev/null
+++ b/src/Game.hx
@@ -0,0 +1,17 @@
+import Const;
+
+@:publicFields
+class Game extends hxd.App {
+ public var scene : h2d.Scene;
+ public var font : h2d.Font;
+ public var world : World;
+
+ override function init() {
+ scene = s2d;
+ s2d.setFixedSize(Const.W, Const.H + 12);
+ world = new World(Res.map, Res.tiles);
+ s2d.add(world.root, 0);
+ }
+
+ public static var inst : Game;
+}
diff --git a/src/Main.hx b/src/Main.hx
index 6698429..b7c41e8 100644
--- a/src/Main.hx
+++ b/src/Main.hx
@@ -41,6 +41,9 @@ class Main extends hxd.App {
onResize();
var root = new ContainerComp(Right, center);
+ root.btnNewGame.onClick = function() {
+ Game.inst = new Game();
+ }
root.btnContinueGame.onClick = function() {
root.btnContinueGame.dom.addClass("highlight");
}
diff --git a/src/Res.hx b/src/Res.hx
new file mode 100644
index 0000000..da5ce0b
--- /dev/null
+++ b/src/Res.hx
@@ -0,0 +1 @@
+typedef Res = hxd.Res;
diff --git a/src/World.hx b/src/World.hx
new file mode 100644
index 0000000..28ebe12
--- /dev/null
+++ b/src/World.hx
@@ -0,0 +1,54 @@
+class World {
+
+ var game : Game;
+ var map : hxd.res.TiledMap.TiledMapData;
+ public var root : h2d.Object;
+ var layers : Map < String, { name : String, data : Array, g : h2d.TileGroup, alpha : Float } > ;
+ var tiles : Array;
+ public var width : Int;
+ public var height : Int;
+
+ public function new( r : hxd.res.TiledMap, tiles : hxd.res.Image ) {
+ game = Game.inst;
+ root = new h2d.Object();
+ map = r.toMap();
+ root = new h2d.Object();
+ width = map.width;
+ height = map.height;
+ var t = tiles.toTile();
+ layers = new Map();
+ var font : h2d.Font = hxd.res.DefaultFont.get();
+ this.tiles = [for( y in 0...Std.int(t.height) >> 5 ) for( x in 0...Std.int(t.width) >> 5 ) t.sub(x * 32, y * 32, 32, 32)];
+ for( ld in map.layers ) {
+ if( ld.name == "hotspots") continue;
+ var l = {
+ name : ld.name,
+ data : ld.data,
+ g : new h2d.TileGroup(t, root),
+ alpha : ld.opacity,
+ }
+ // l.g.colorKey = 0x1D8700;
+ l.g.alpha = ld.opacity;
+ layers.set(ld.name, l);
+ rebuildLayer(ld.name);
+ }
+ }
+
+ function rebuildLayer( name : String ) {
+ var l = layers.get(name);
+ if( l == null ) return;
+ var pos = 0;
+ var g = l.g;
+ g.clear();
+ while( g.numChildren > 0 )
+ g.getChildAt(0).remove();
+
+ for( y in 0...height )
+ for( x in 0...width ) {
+ var t = l.data[pos++] - 1;
+ if( t < 0 ) continue;
+ g.add(x * 32, y * 32, tiles[t]);
+ }
+ }
+
+}