diff --git a/examples/lib-test/favicon.png b/examples/lib-test/favicon.png
new file mode 100644
index 0000000..b353a1c
Binary files /dev/null and b/examples/lib-test/favicon.png differ
diff --git a/examples/lib-test/index.html b/examples/lib-test/index.html
new file mode 100644
index 0000000..99632cd
--- /dev/null
+++ b/examples/lib-test/index.html
@@ -0,0 +1,13 @@
+
+
+
+ Game
+
+
+
+
+
+
+
+
+
diff --git a/examples/lib-test/package.json b/examples/lib-test/package.json
new file mode 100644
index 0000000..b935148
--- /dev/null
+++ b/examples/lib-test/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "asdf-lib-test",
+ "version": "1.0.0",
+ "description": "Library test",
+ "main": "index.html",
+ "directories": {
+ "lib": "lib"
+ },
+ "scripts": {
+ "test": "na"
+ },
+ "keywords": [
+ "library",
+ "test",
+ "asdf"
+ ],
+ "author": "Arne van Iterson",
+ "license": "ISC"
+}
\ No newline at end of file
diff --git a/examples/lib-test/res/images/building.png b/examples/lib-test/res/images/building.png
new file mode 100644
index 0000000..102554d
Binary files /dev/null and b/examples/lib-test/res/images/building.png differ
diff --git a/examples/lib-test/res/images/characters.png b/examples/lib-test/res/images/characters.png
new file mode 100644
index 0000000..432e6c6
Binary files /dev/null and b/examples/lib-test/res/images/characters.png differ
diff --git a/examples/lib-test/res/images/rc2000.png b/examples/lib-test/res/images/rc2000.png
new file mode 100644
index 0000000..748dfdb
Binary files /dev/null and b/examples/lib-test/res/images/rc2000.png differ
diff --git a/examples/lib-test/res/images/rick.png b/examples/lib-test/res/images/rick.png
new file mode 100644
index 0000000..3be8d6f
Binary files /dev/null and b/examples/lib-test/res/images/rick.png differ
diff --git a/examples/lib-test/res/images/spaceship.png b/examples/lib-test/res/images/spaceship.png
new file mode 100644
index 0000000..4b69658
Binary files /dev/null and b/examples/lib-test/res/images/spaceship.png differ
diff --git a/examples/lib-test/res/images/tiles_packed.png b/examples/lib-test/res/images/tiles_packed.png
new file mode 100644
index 0000000..ba371cf
Binary files /dev/null and b/examples/lib-test/res/images/tiles_packed.png differ
diff --git a/examples/lib-test/res/main.css b/examples/lib-test/res/main.css
new file mode 100644
index 0000000..9a218f0
--- /dev/null
+++ b/examples/lib-test/res/main.css
@@ -0,0 +1,17 @@
+body {
+ background-color: rgba(42, 42, 46, 1);
+ text-align: center;
+
+ -moz-user-select: none;
+ -webkit-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+#board {
+ position: relative;
+ background-color: #111;
+ width: max-content;
+ height: auto;
+ margin: auto;
+ border: 5px solid whitesmoke;
+}
diff --git a/examples/lib-test/src/main.js b/examples/lib-test/src/main.js
new file mode 100644
index 0000000..549a1a9
--- /dev/null
+++ b/examples/lib-test/src/main.js
@@ -0,0 +1,48 @@
+import asdf from "../../../asdf/index.js";
+const { Game, Container, CanvasRenderer, math, KeyControls, MouseControls, Text, Texture, Sprite } = asdf;
+
+const game = new Game(640, 320, false);
+const { scene, w, h } = game;
+
+const buildings = scene.add(new Container());
+const makeRandom = (b, x) => {
+ b.scale.x = math.randf(1,3);
+ b.scale.y = math.randf(1,3);
+ b.pos.x = x;
+ b.pos.y = h - b.scale.y * 64;
+};
+
+for (let x = 0; x < 50; x++) {
+ const b = buildings.add(new Sprite(new Texture("res/images/building.png")));
+ makeRandom(b, math.rand(w));
+}
+
+var rotation = 0;
+const ship = new Sprite(new Texture("res/images/spaceship.png"));
+ship.pivot = { x: 16, y: 16 };
+scene.add(ship);
+
+
+game.run((dt ,t) => {
+ ship.update = function(dt, t) {
+ const {scale} = this;
+ scale.x = Math.abs(Math.sin(t)) + 1;
+ scale.y = Math.abs(Math.sin(t)) + 1;
+
+ rotation = rotation + 0.2;
+ ship.rotation = rotation;
+
+ ship.pos.y = (Math.abs(Math.sin(t))) * 50 + (h / 2) - 16;
+ ship.pos.x += dt * 50;
+ if (ship.pos.x > w) {
+ ship.pos.x = -32;
+ }
+ }
+
+ buildings.map(b => {
+ b.pos.x -= 100 * dt;
+ if (b.pos.x < -80) {
+ makeRandom(b,w);
+ }
+ });
+});
diff --git a/examples/tile-test/entities/King.js b/examples/tile-test/entities/King.js
new file mode 100644
index 0000000..0c8c360
--- /dev/null
+++ b/examples/tile-test/entities/King.js
@@ -0,0 +1,41 @@
+import asdf from "../../../asdf/index.js";
+const { TileSprite, Texture, math } = asdf;
+const texture = new Texture("./res/images/characters.png");
+
+class King extends TileSprite {
+ constructor () {
+ super(texture, 32, 32);
+ this.scale = { x: 2, y: 2 };
+
+ this.rate = 0.1;
+ this.frames = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 1 },
+ { x: 3, y: 1 }
+ ];
+ this.curTime = 0;
+ this.curFrame = math.rand(0, this.frames.length);
+ this.frame = this.frames[this.curFrame];
+
+ this.speed = math.rand(20, 100)
+ this.pos.y = math.rand(-16, 304);
+ this.pos.x = math.rand(-32, 640);
+ }
+ update (dt, t) {
+ const { rate, frames } = this;
+ this.curTime += dt;
+ if (this.curTime > rate) {
+ this.frame = frames[this.curFrame++ % frames.length];
+ this.curTime -= rate;
+ }
+
+ this.pos.x += (dt * this.speed);
+ if (this.pos.x > 640 + 32) {
+ this.pos.y = math.rand(-16, 304);
+ this.pos.x = -32;
+ }
+ }
+}
+
+export default King;
\ No newline at end of file
diff --git a/examples/tile-test/entities/Snake.js b/examples/tile-test/entities/Snake.js
new file mode 100644
index 0000000..bff3f20
--- /dev/null
+++ b/examples/tile-test/entities/Snake.js
@@ -0,0 +1,41 @@
+import asdf from "../../../asdf/index.js";
+const { TileSprite, Texture, math } = asdf;
+const texture = new Texture("./res/images/characters.png");
+
+class Snake extends TileSprite {
+ constructor () {
+ super(texture, 32, 32);
+ this.scale = { x: 2, y: 2 };
+
+ this.rate = 0.1;
+ this.curTime = 0;
+ this.curFrame = 0;
+ this.frames = [
+ { x: 0, y: 3 },
+ { x: 1, y: 3 },
+ { x: 2, y: 3 },
+ { x: 3, y: 3 }
+ ];
+ this.frame = this.frames[this.curFrame];
+
+ this.speed = math.rand(50, 100)
+ this.pos.y = math.rand(0, 320);
+ this.pos.x = math.rand(-32, 320);
+ }
+ update (dt, t) {
+ const { rate, frames } = this;
+ this.curTime += dt;
+ if (this.curTime > rate) {
+ this.frame = frames[this.curFrame++ % frames.length];
+ this.curTime -= rate;
+ }
+
+ this.pos.x += (dt * this.speed);
+ if (this.pos.x > 640 + 32) {
+ this.pos.y = math.rand(-16, 304);
+ this.pos.x = -32;
+ }
+ }
+}
+
+export default Snake;
\ No newline at end of file
diff --git a/examples/tile-test/favicon.png b/examples/tile-test/favicon.png
new file mode 100644
index 0000000..b353a1c
Binary files /dev/null and b/examples/tile-test/favicon.png differ
diff --git a/examples/tile-test/index.html b/examples/tile-test/index.html
new file mode 100644
index 0000000..99632cd
--- /dev/null
+++ b/examples/tile-test/index.html
@@ -0,0 +1,13 @@
+
+
+
+ Game
+
+
+
+
+
+
+
+
+
diff --git a/examples/tile-test/package.json b/examples/tile-test/package.json
new file mode 100644
index 0000000..2ec5fe9
--- /dev/null
+++ b/examples/tile-test/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "asdf-tile-test",
+ "version": "1.0.0",
+ "description": "Spritesheet test",
+ "main": "index.html",
+ "directories": {
+ "lib": "lib"
+ },
+ "scripts": {
+ "test": "na"
+ },
+ "keywords": [
+ "spritesheet",
+ "opengameart",
+ "tile",
+ "test",
+ "asdf"
+ ],
+ "author": "Arne van Iterson",
+ "license": "ISC"
+}
\ No newline at end of file
diff --git a/examples/tile-test/res/images/building.png b/examples/tile-test/res/images/building.png
new file mode 100644
index 0000000..102554d
Binary files /dev/null and b/examples/tile-test/res/images/building.png differ
diff --git a/examples/tile-test/res/images/characters.png b/examples/tile-test/res/images/characters.png
new file mode 100644
index 0000000..432e6c6
Binary files /dev/null and b/examples/tile-test/res/images/characters.png differ
diff --git a/examples/tile-test/res/images/rc2000.png b/examples/tile-test/res/images/rc2000.png
new file mode 100644
index 0000000..748dfdb
Binary files /dev/null and b/examples/tile-test/res/images/rc2000.png differ
diff --git a/examples/tile-test/res/images/rick.png b/examples/tile-test/res/images/rick.png
new file mode 100644
index 0000000..3be8d6f
Binary files /dev/null and b/examples/tile-test/res/images/rick.png differ
diff --git a/examples/tile-test/res/images/tiles_packed.png b/examples/tile-test/res/images/tiles_packed.png
new file mode 100644
index 0000000..ba371cf
Binary files /dev/null and b/examples/tile-test/res/images/tiles_packed.png differ
diff --git a/examples/tile-test/res/main.css b/examples/tile-test/res/main.css
new file mode 100644
index 0000000..9a218f0
--- /dev/null
+++ b/examples/tile-test/res/main.css
@@ -0,0 +1,17 @@
+body {
+ background-color: rgba(42, 42, 46, 1);
+ text-align: center;
+
+ -moz-user-select: none;
+ -webkit-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+#board {
+ position: relative;
+ background-color: #111;
+ width: max-content;
+ height: auto;
+ margin: auto;
+ border: 5px solid whitesmoke;
+}
diff --git a/examples/tile-test/src/main.js b/examples/tile-test/src/main.js
new file mode 100644
index 0000000..369d1fe
--- /dev/null
+++ b/examples/tile-test/src/main.js
@@ -0,0 +1,25 @@
+import asdf from "../../../asdf/index.js";
+const { Game, Container, CanvasRenderer, math, KeyControls, MouseControls, Text, Texture, Sprite, TileSprite } = asdf;
+
+const game = new Game(640, 320, true);
+const { scene, w, h } = game;
+
+import King from "../entities/King.js";
+import Snake from "../entities/Snake.js";
+
+var snake = new Snake();
+console.log(snake);
+scene.add(snake);
+
+
+for (let index = 0; index < 250; index++) {
+ scene.add(new King());
+}
+
+const mouseAim = new MouseControls();
+
+game.run((dt ,t) => {
+ if (mouseAim.isDown) {
+ console.log('cliccccccccccc');
+ }
+});
diff --git a/examples/tilemap-test/index.html b/examples/tilemap-test/index.html
new file mode 100644
index 0000000..99632cd
--- /dev/null
+++ b/examples/tilemap-test/index.html
@@ -0,0 +1,13 @@
+
+
+
+ Game
+
+
+
+
+
+
+
+
+
diff --git a/examples/tilemap-test/res/images/allSprites_default.png b/examples/tilemap-test/res/images/allSprites_default.png
new file mode 100644
index 0000000..d58cd40
Binary files /dev/null and b/examples/tilemap-test/res/images/allSprites_default.png differ
diff --git a/examples/tilemap-test/res/images/allSprites_default.xml b/examples/tilemap-test/res/images/allSprites_default.xml
new file mode 100644
index 0000000..b2150bd
--- /dev/null
+++ b/examples/tilemap-test/res/images/allSprites_default.xml
@@ -0,0 +1,189 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/tilemap-test/res/images/building.png b/examples/tilemap-test/res/images/building.png
new file mode 100644
index 0000000..102554d
Binary files /dev/null and b/examples/tilemap-test/res/images/building.png differ
diff --git a/examples/tilemap-test/res/images/characters.png b/examples/tilemap-test/res/images/characters.png
new file mode 100644
index 0000000..432e6c6
Binary files /dev/null and b/examples/tilemap-test/res/images/characters.png differ
diff --git a/examples/tilemap-test/res/images/rc2000.png b/examples/tilemap-test/res/images/rc2000.png
new file mode 100644
index 0000000..748dfdb
Binary files /dev/null and b/examples/tilemap-test/res/images/rc2000.png differ
diff --git a/examples/tilemap-test/res/images/rick.png b/examples/tilemap-test/res/images/rick.png
new file mode 100644
index 0000000..3be8d6f
Binary files /dev/null and b/examples/tilemap-test/res/images/rick.png differ
diff --git a/examples/tilemap-test/res/images/tiles.png b/examples/tilemap-test/res/images/tiles.png
new file mode 100644
index 0000000..e24ecd6
Binary files /dev/null and b/examples/tilemap-test/res/images/tiles.png differ
diff --git a/examples/tilemap-test/res/images/tiles_packed.png b/examples/tilemap-test/res/images/tiles_packed.png
new file mode 100644
index 0000000..ba371cf
Binary files /dev/null and b/examples/tilemap-test/res/images/tiles_packed.png differ
diff --git a/examples/tilemap-test/res/main.css b/examples/tilemap-test/res/main.css
new file mode 100644
index 0000000..9a218f0
--- /dev/null
+++ b/examples/tilemap-test/res/main.css
@@ -0,0 +1,17 @@
+body {
+ background-color: rgba(42, 42, 46, 1);
+ text-align: center;
+
+ -moz-user-select: none;
+ -webkit-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+#board {
+ position: relative;
+ background-color: #111;
+ width: max-content;
+ height: auto;
+ margin: auto;
+ border: 5px solid whitesmoke;
+}
diff --git a/examples/tilemap-test/src/main.js b/examples/tilemap-test/src/main.js
new file mode 100644
index 0000000..434bd84
--- /dev/null
+++ b/examples/tilemap-test/src/main.js
@@ -0,0 +1,28 @@
+import asdf from "../../../asdf/index.js";
+const { Game, Container, CanvasRenderer, math, KeyControls, MouseControls, Text, Texture, Sprite, TileSprite, TileMap, TileMapXML, SpriteSheetXML } = asdf;
+
+const game = new Game(640, 320, true);
+const { scene, w, h } = game;
+
+const mouseAim = new MouseControls();
+
+const tanksTexture = new Texture("./res/images/allSprites_default.png")
+const tanksXml = new SpriteSheetXML("./res/images/allSprites_default.xml");
+const map = { x: 640 / 64, y: 320 / 64 };
+
+// Make a random level of tile indexes
+const level = [
+ 135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
+ 135, 135, 135, 135, 135, 135, 135, 135, 135, 135,
+ 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
+ 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
+ 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
+];
+
+scene.add(new TileMapXML(level, map.x, map.y, tanksTexture, tanksXml));
+
+game.run((dt, t) => {
+ if (mouseAim.isDown) {
+ console.log('cliccccccccccc');
+ }
+});