From cb8cd2190f2099b41b222e39e78d398c9a62c998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 11 Aug 2014 02:32:28 +0200 Subject: [PATCH] Tiled maps etc --- android/assets/colorwheel.png | Bin 0 -> 2849 bytes android/assets/map_pieces/p1.tmx | 344 ++++++++++ android/assets/map_pieces/p2.tmx | 648 ++++++++++++++++++ android/assets/map_pieces/p3.tmx | 648 ++++++++++++++++++ android/assets/map_pieces/p4.tmx | 344 ++++++++++ .../game/renderer/AbstractGameRenderer.java | 8 +- .../colorrunner/game/renderer/CRAssets.java | 5 + .../game/renderer/CRGameRenderer.java | 8 +- .../colorrunner/game/world/CRGameWorld.java | 109 +-- .../game/world/map/CRMapStorage.java | 27 + .../game/world/map/CRTiledMap.java | 56 ++ data/Tileset.pdn | Bin 0 -> 5633 bytes data/Tileset.png | Bin 0 -> 913 bytes data/Tileset.tsx | 4 + 14 files changed, 2142 insertions(+), 59 deletions(-) create mode 100644 android/assets/colorwheel.png create mode 100644 android/assets/map_pieces/p1.tmx create mode 100644 android/assets/map_pieces/p2.tmx create mode 100644 android/assets/map_pieces/p3.tmx create mode 100644 android/assets/map_pieces/p4.tmx create mode 100644 core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java create mode 100644 core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java create mode 100644 data/Tileset.pdn create mode 100644 data/Tileset.png create mode 100644 data/Tileset.tsx diff --git a/android/assets/colorwheel.png b/android/assets/colorwheel.png new file mode 100644 index 0000000000000000000000000000000000000000..961704dd4407f73b25aa527336322dcf837004e0 GIT binary patch literal 2849 zcmV++3*PjJP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02p*dSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E;Eegmrwuz3X(}gK~#8N<=qdA6!jGc@P~lq@Q!~+Tg0L* z6q?wWT8elAYB3ZrgyL!VCyk~}j7T*RDcAtY-+)z%5h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JmWhqB5tDA2eUAOr zSD$hhpYPf=B(A^qnW7<8ipFnH)cdHSc{46i)sXIDqin>a8;x|OT5#b)`}nWS{k0rg zJo}EAl+iv{su|n14O5*ueXbW(sQxH6NgyU=e98sm1ETUjYv#?Hp%+!C)4g<4PbW4Olg*=YS4zWg&uT>#qD|oWG~zj6fqejEO8X9h8kXa zL|uh7QvE>_lR?8$+d^j;47=eZG=jY;xo`;_Cs+xam<$`L=nLau8&?#f_h3CZPO6ei zVltOdQ5h_NDy|NAdq3Ggmgytu3RIiZ??A>c00v1+Mgb}-f?nqIKv)61wKf;{X^yKu zU|xR;7tQH4uobxZ6;KbefcK9|;4Xbx(V^)7Me)^?+)I-~00000NkvXXu0mjf;HY>a literal 0 HcmV?d00001 diff --git a/android/assets/map_pieces/p1.tmx b/android/assets/map_pieces/p1.tmx new file mode 100644 index 0000000..281f5e8 --- /dev/null +++ b/android/assets/map_pieces/p1.tmx @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/assets/map_pieces/p2.tmx b/android/assets/map_pieces/p2.tmx new file mode 100644 index 0000000..e07b927 --- /dev/null +++ b/android/assets/map_pieces/p2.tmx @@ -0,0 +1,648 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/assets/map_pieces/p3.tmx b/android/assets/map_pieces/p3.tmx new file mode 100644 index 0000000..2c35a90 --- /dev/null +++ b/android/assets/map_pieces/p3.tmx @@ -0,0 +1,648 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/assets/map_pieces/p4.tmx b/android/assets/map_pieces/p4.tmx new file mode 100644 index 0000000..8174632 --- /dev/null +++ b/android/assets/map_pieces/p4.tmx @@ -0,0 +1,344 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java index 542c830..b803a1e 100644 --- a/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java +++ b/core/src/de/samdev/colorrunner/game/renderer/AbstractGameRenderer.java @@ -9,15 +9,15 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Vector3; public abstract class AbstractGameRenderer { - private final static float GAME_HEIGHT = 512; - private final static float MIN_GAME_WIDTH = 672; // ~ 512 * (4/3) - private final static float MAX_GAME_WIDTH = 1024; // ~ 512 * (2/1) // ~~ 16:9 + public final static float GAME_HEIGHT = 512; + public final static float MIN_GAME_WIDTH = 672; // ~ 512 * (4/3) + public final static float MAX_GAME_WIDTH = 1024; // ~ 512 * (2/1) // ~~ 16:9 private final static float FREE_ROAM_WIDTH = 1f/4f; private int debugTextCount; - private OrthographicCamera cam; + protected OrthographicCamera cam; protected ShapeRenderer shapeRenderer; protected BitmapFont font = new BitmapFont(); diff --git a/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java b/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java index 4fe36a5..499d3c5 100644 --- a/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java +++ b/core/src/de/samdev/colorrunner/game/renderer/CRAssets.java @@ -1,5 +1,6 @@ package de.samdev.colorrunner.game.renderer; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.Texture; @@ -15,6 +16,8 @@ public class CRAssets { public static Texture TEX_FLOORTILE_LEFT; public static Texture TEX_FLOORTILE_RIGHT; + public static Texture TEX_COLORWHEEL; + static { { Pixmap pixmap = new Pixmap(64, 64, Format.RGBA8888); @@ -71,5 +74,7 @@ public class CRAssets { pixmap.fill(); TEX_FLOORTILE_LEFT = new Texture(pixmap); } + + TEX_COLORWHEEL = new Texture(Gdx.files.internal("colorwheel.png")); } } diff --git a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java index 26bb50b..7e50a09 100644 --- a/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java +++ b/core/src/de/samdev/colorrunner/game/renderer/CRGameRenderer.java @@ -1,7 +1,9 @@ package de.samdev.colorrunner.game.renderer; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.math.Vector3; import de.samdev.colorrunner.game.world.CRGameWorld; import de.samdev.colorrunner.game.world.entities.CRGameEntity; @@ -28,7 +30,11 @@ public class CRGameRenderer extends AbstractGameRenderer { endDebug(); spriteBatch.begin(); - spriteBatch.disableBlending(); // Performance, bitches + + spriteBatch.enableBlending(); + Vector3 cw_coords = cam.unproject(new Vector3(Gdx.graphics.getWidth(), 0, 0)); + spriteBatch.draw(CRAssets.TEX_COLORWHEEL, cw_coords.x - 70, cw_coords.y - 70, 64, 64); + spriteBatch.disableBlending(); for (CRGameEntity e : gameworld.entities) { spriteBatch.draw(e.getTexture(), e.bounds.x, e.bounds.y, e.bounds.width, e.bounds.height); diff --git a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java index 834d385..7d02581 100644 --- a/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java +++ b/core/src/de/samdev/colorrunner/game/world/CRGameWorld.java @@ -3,78 +3,34 @@ package de.samdev.colorrunner.game.world; import java.util.ArrayList; import java.util.List; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Vector2; + +import de.samdev.colorrunner.game.renderer.AbstractGameRenderer; import de.samdev.colorrunner.game.world.entities.CRGameEntity; import de.samdev.colorrunner.game.world.entities.gameentities.PlayerEntity; import de.samdev.colorrunner.game.world.entities.gameentities.floor.DownStateFloorTileEntity; +import de.samdev.colorrunner.game.world.entities.gameentities.floor.FloorTileEntity; import de.samdev.colorrunner.game.world.entities.gameentities.floor.LeftStateFloorTileEntity; import de.samdev.colorrunner.game.world.entities.gameentities.floor.RightStateFloorTileEntity; import de.samdev.colorrunner.game.world.entities.gameentities.floor.UpStateFloorTileEntity; +import de.samdev.colorrunner.game.world.map.CRMapStorage; +import de.samdev.colorrunner.game.world.map.CRTiledMap; import de.samdev.colorrunner.input.GameInputListener; public class CRGameWorld implements GameInputListener { - public PlayerEntity player; public List entities = new ArrayList(); public FPSCounter fps = new FPSCounter(); + private float mapRightBoundary = 0; + public CRGameWorld() { - addEntity(player = new PlayerEntity(this, 40, 290)); - addEntity(new UpStateFloorTileEntity(this, 1 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 2 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 3 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 4 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 5 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 6 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 7 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 8 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 9 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 10 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 11 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 12 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 13 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 14 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 15 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 16 * 32, 32)); - addEntity(new UpStateFloorTileEntity(this, 17 * 32, 32)); - - addEntity(new UpStateFloorTileEntity(this, 18 * 32, 1 * 32)); - addEntity(new UpStateFloorTileEntity(this, 19 * 32, 2 * 32)); - addEntity(new UpStateFloorTileEntity(this, 19 * 32, 3 * 32)); - addEntity(new UpStateFloorTileEntity(this, 18 * 32, 4 * 32)); - addEntity(new UpStateFloorTileEntity(this, 18 * 32, 5 * 32)); - addEntity(new UpStateFloorTileEntity(this, 19 * 32, 6 * 32)); - addEntity(new UpStateFloorTileEntity(this, 20 * 32, 7 * 32)); - - addEntity(new RightStateFloorTileEntity(this, 21 * 32, 32)); - addEntity(new RightStateFloorTileEntity(this, 22 * 32, 32)); - addEntity(new RightStateFloorTileEntity(this, 26 * 32, 32)); - addEntity(new RightStateFloorTileEntity(this, 27 * 32, 32)); - addEntity(new RightStateFloorTileEntity(this, 28 * 32, 32)); - addEntity(new RightStateFloorTileEntity(this, 29 * 32, 32)); - addEntity(new RightStateFloorTileEntity(this, 29 * 32, 64)); - - addEntity(new LeftStateFloorTileEntity(this, 32 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 33 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 34 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 35 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 36 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 37 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 38 * 32, 32)); - addEntity(new LeftStateFloorTileEntity(this, 39 * 32, 32)); - - addEntity(new DownStateFloorTileEntity(this, 11 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 12 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 13 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 14 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 15 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 16 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 17 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 18 * 32, 456)); - addEntity(new DownStateFloorTileEntity(this, 19 * 32, 456)); + expandMap(); } public void update(float delta) { @@ -83,6 +39,15 @@ public class CRGameWorld implements GameInputListener { for (CRGameEntity ent : entities) { ent.update(delta); } + + expandMap(); + } + + private void expandMap() { + while (player.bounds.x + AbstractGameRenderer.MAX_GAME_WIDTH*2 > mapRightBoundary) { + float width = appendMap(CRMapStorage.getMap(), new Vector2(mapRightBoundary, 0)); + mapRightBoundary += width; + } } public CRGameEntity addEntity(CRGameEntity ent) { @@ -91,6 +56,42 @@ public class CRGameWorld implements GameInputListener { return ent; } + private float appendMap(CRTiledMap map, Vector2 pos) { + int height = map.getHeight(); + int width = map.getWidth(); + + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + float px = pos.x + x * FloorTileEntity.FLOORTILE_WIDTH; + float py = pos.y + (height - y) * FloorTileEntity.FLOORTILE_WIDTH; + + switch (map.getGID(x, y)) { + + case CRTiledMap.GID_EMPTY: break; + + case CRTiledMap.GID_UP: + addEntity(new UpStateFloorTileEntity(this, px, py)); + break; + case CRTiledMap.GID_RIGHT: + addEntity(new RightStateFloorTileEntity(this, px, py)); + break; + case CRTiledMap.GID_DOWN: + addEntity(new DownStateFloorTileEntity(this, px, py)); + break; + case CRTiledMap.GID_LEFT: + addEntity(new LeftStateFloorTileEntity(this, px, py)); + break; + + default: + Gdx.app.error("MapLoad", "Unknown GID: " + map.getGID(x, y)); + break; + } + } + } + + return width * FloorTileEntity.FLOORTILE_WIDTH; + } + @Override public void doJump() { player.jump(); diff --git a/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java b/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java new file mode 100644 index 0000000..1bc10ab --- /dev/null +++ b/core/src/de/samdev/colorrunner/game/world/map/CRMapStorage.java @@ -0,0 +1,27 @@ +package de.samdev.colorrunner.game.world.map; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import com.badlogic.gdx.Gdx; + +public class CRMapStorage { + public static final Random random = new Random(); + public static final List maps = new ArrayList(); + + public static final CRTiledMap map_01 = register("p1.tmx"); + public static final CRTiledMap map_02 = register("p2.tmx"); + public static final CRTiledMap map_03 = register("p3.tmx"); + public static final CRTiledMap map_04 = register("p4.tmx"); + + public static CRTiledMap register(String path) { + CRTiledMap m = CRTiledMap.load(Gdx.files.internal("map_pieces/" + path).readString()); + maps.add(m); + return m; + } + + public static CRTiledMap getMap() { + return maps.get(random.nextInt(maps.size())); + } +} diff --git a/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java b/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java new file mode 100644 index 0000000..c9d0887 --- /dev/null +++ b/core/src/de/samdev/colorrunner/game/world/map/CRTiledMap.java @@ -0,0 +1,56 @@ +package de.samdev.colorrunner.game.world.map; + +import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.XmlReader; +import com.badlogic.gdx.utils.XmlReader.Element; + +public class CRTiledMap { + public final static int GID_EMPTY = 0; + + public final static int GID_MID = 13; + public final static int GID_UP = 8; + public final static int GID_RIGHT = 14; + public final static int GID_DOWN = 18; + public final static int GID_LEFT = 12; + + public int width; + public int height; + + public int[][] map; + + public static CRTiledMap load(String inputXmlString) { + CRTiledMap result = new CRTiledMap(); + + XmlReader reader = new XmlReader(); + Element root = reader.parse(inputXmlString); + + Element elemLayer = root.getChildByName("layer"); + Element elemData = elemLayer.getChildByName("data"); + Array tiles = elemData.getChildrenByName("tile"); + + int width = elemLayer.getInt("width"); + int height = elemLayer.getInt("height"); + + result.map = new int[width][height]; + result.width = width; + result.height = height; + + for (int i = 0; i < tiles.size; i++) { + result.map[i % width][i / width] = tiles.get(i).getInt("gid"); + } + + return result; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public int getGID(int x, int y) { + return map[x][y]; + } +} diff --git a/data/Tileset.pdn b/data/Tileset.pdn new file mode 100644 index 0000000000000000000000000000000000000000..eb0c7f2398478cfe6f7f6aff4b4dc7d72f0d94f8 GIT binary patch literal 5633 zcmd^CdyE^!8Mn!u@0+yQe>)rM4 z`dN}7BoI=ITD3)@4WeqRJ_JRlR-*54g;s)6sER~H1>(^Xfg&1?fFOkAa-CV*cQ$zt zD)q1Io@eKq$8Wy*ecycFT+A1-)CN?eLY@njNgC+tOkOU!^-iN+R|E`Ql-qTdYyweo z>n(bnMAkrlnvsiX*uwCfTW=k)jMywD`-s(OG@JGNMyaYK^W}Y`a(2;>zTAC zny4E?0h-6*6G;-qae{_5KN3B0FFp&u-spHCB%>C5CX!4TgSaSJDSI3>B)B+X^1v~T zg?i078z)fXBsE^lP<0&lNnt2Dd^nY_RRU;2D48S@p7cZ!I5I^KCCm6Y9y4KBLGV~A z!C=MEvPJ7bf?hBOQ+1p$8PgOGcn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2=Q@z%O`&=KK z*{In88+tsz?Ce_VJRacWpa(>0-KJDjGu?rQu zVX<-Z9$5BeZ!a%`-h|crkHW|2EhT%SH9p;&Vm*vpCIuzYDhXT=c>#zr1Ee9TDi%lz zY*9K5>zRF1yFp3po7?qvdhd)}hfvbNz|9v}&(O1WY;9Q-6Rz!@k!-7h*ia7-@9gbr zFRqmR07`cH0-T}!A}rSP=1m9$QLJ$NC0NlKV6i@6FBH^>er3STu%aD-#rgmY3WEsw zlkEy+%Ap+e+#He?tN|urFOXE z&5YzBsS+*nRW3io3nazJO|3#jn9l?C1_W`rT;=!8K;c$Q(g{qGL$xvXwj3jhK&Vl_3>OsdvfgOdF&X&yGEvX;x zfgD7>dWk0kj#N&@Aad0U`8IN_VR*1;xoEd)i=-4&?!v=)PynI`@~~U0RwM6Mp*nih zLx^nU!im0@$%RvmTm!MMMxKBuT_;41?5p%4bN2Ubf(I83MvvOQqV9eK~sx!kcHGzW>&f z@11?&`O~HB^5Xu(OYdKTu+kcP?h=Qt4XZA_jD3P7I`bA!dSCiPs-byftFP=HZL_>a zq3S2=6dr%}u`6%aZ5zZth6Qf8d^ryvVA5%DP_~dw0i2G*(~Tqw#aWt#=r=+!9|t zc984?emnfA?ZBbkm|f`0ZWjZ}JGef9$E3PCvPQ>_Gi{N4RHACtiC# zd**`^f4hF{fcw7r%3H~QKM{46=IhI=n#I4Kng5q#>5V5JK6UT0%pVUOaZm2wx%3Y{ zw{8E}gV~k2AKmfpp_R-7uguXazux>C_SBtM&6VE#{dW)CeEQJJH}71ggxiiR|KMxS z9Gxzd@=K4bJo0z`=x?R@r%oMyk|$GhBU?`0_|A)m-gx%RffM)K_WGW{8UH)KdjY#U z`)a-Beg=D+eg8X|55d_7Mjtx!!F#tJ{qr|=EZuP8wI?thid!uQ&M5nVTcTSV-hRP) H6mj!kh1Fu; literal 0 HcmV?d00001 diff --git a/data/Tileset.png b/data/Tileset.png new file mode 100644 index 0000000000000000000000000000000000000000..bdfe1087f0be3daff9824a8e7ae2b972be7760d1 GIT binary patch literal 913 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r51|<6gKdl8)Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXWa8_I?z;Reoq(2 zkczmsmoD}xEAqHp{PW*GJ+Vr9<}2wW_LF-gN-hLk5Zn0dYu*0SY&_laZAbYJKWb0> zczDB)#E3rzI&~6a_E?3Nz4E_t@!DhqpQXHpasO|=S-4g`afX+4QV6r{7DYGH3(itS z=4Z|NHbKOtoX#%F$$0H4v20RXz-A5UTUA1BE0-u<(K*$&ZC*>FRwjpOH*rc=eQQZ= zKJqv(+W(Nj)XWnZrw(DVuiov5-}+UBCs~1O!~a10n{)cvSra9gFE;)Cxa)uCHI8#H z3+)dWuq|T!o&5G5U$y()noporRncvK0MROxNz#kCOX+KkfPp-IxCqI|+5v$BW07|1P`n zyX4++i_4k&9F5=}=(&6U@VscNV>7SxoQun1Z!;9oy&<3d{riUJPvn#*&$H%TC^YPlTd-J6J3e4=M|+D(WNMyuKCmh#RFW!`_O%>^WeH<6;H e-HN^O{~4IQ9J+!tjGh6r4}+(xpUXO@geCx&1*=#9 literal 0 HcmV?d00001 diff --git a/data/Tileset.tsx b/data/Tileset.tsx new file mode 100644 index 0000000..1c4f42e --- /dev/null +++ b/data/Tileset.tsx @@ -0,0 +1,4 @@ + + + +