|
| 1 | + |
| 2 | +# **Tiles** |
| 3 | + |
| 4 | +> Commandline tool that makes building tilesets and rendering static tilemaps super easy! |
| 5 | +
|
| 6 | +**Features** |
| 7 | + |
| 8 | +- create your own tilesets _"libraries"_ (ready to reuse) |
| 9 | +- inspect, list and extract tiles from tilesets |
| 10 | +- define a tilemap using one or more tileset |
| 11 | +- render a tilemap as PNG images |
| 12 | +- eventually add a watermark to the tilemap |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +### Overview |
| 17 | + |
| 18 | +Tilemaps are a very popular technique in 2D game development, consisting of building the game world or level map out of small, regular-shaped images called tiles. |
| 19 | + |
| 20 | +The most efficient way to store the tile images is in an atlas or tileset |
| 21 | + |
| 22 | +- all of the required tiles grouped together in a single image file |
| 23 | + |
| 24 | +When it's time to draw a tile, only a small section of this bigger image is rendered on the grid. |
| 25 | + |
| 26 | +#### Static square tilemaps |
| 27 | + |
| 28 | +Square-based tilemaps are the most simple implementation for two perspectives: |
| 29 | + |
| 30 | +- top-down (like many RPG's or strategy games) |
| 31 | +- side-view (like platformers such as Super Mario Bros) |
| 32 | +- architecture diagrams...why not!? 😏 |
| 33 | + |
| 34 | +# How to use **tiles** |
| 35 | + |
| 36 | +## All available commands |
| 37 | + |
| 38 | +```bash |
| 39 | +tiles --help |
| 40 | +``` |
| 41 | + |
| 42 | +## Generate a tileset |
| 43 | + |
| 44 | +Let's say you have all your PNG images (square in size, 96x96 for example) in one folder and you want to create a new tileset: |
| 45 | + |
| 46 | +```bash |
| 47 | +tiles compose /path/to/png/images/ |
| 48 | +``` |
| 49 | + |
| 50 | +By default the generated tileset (it's a YAML) is printed on the terminal. If you want to save the result to a file you can redirect `>` the output: |
| 51 | + |
| 52 | +```bash |
| 53 | +tiles compose /path/to/png/images/ > my_tileset.yml |
| 54 | +``` |
| 55 | + |
| 56 | +### Ready-To-Use tilesets |
| 57 | + |
| 58 | +| Set | URL | |
| 59 | +|:-----------------------|:---------------------------------------------------------| |
| 60 | +| AWS Icons | [./examples/aws_tileset.yml](./examples/aws_tileset.yml) | |
| 61 | +| Arrows and Connectors | [./examples/links_tileset.yml](./examples/links_tileset.yml) | |
| 62 | + |
| 63 | + |
| 64 | +## Lists all tiles identifiers contained in the specified tilset |
| 65 | + |
| 66 | +```bash |
| 67 | +tiles list /path/to/my_tileset.yml |
| 68 | +``` |
| 69 | + |
| 70 | +## Extracts the tile PNG with the specified identifier from the tileset |
| 71 | + |
| 72 | +```bash |
| 73 | +tiles pull --id aws_waf ../examples/aws_tileset.yml |
| 74 | +``` |
| 75 | + |
| 76 | +By default the PNG data is dumped on the terminal. If you want to save the result to a file you can redirect `>` the output: |
| 77 | + |
| 78 | +```bash |
| 79 | +tiles pull --id aws_waf ../examples/aws_tileset.yml > aws_waf.png |
| 80 | +``` |
| 81 | + |
| 82 | +## Rendering a static tilemap |
| 83 | + |
| 84 | +The first step is to create the static tilemap using the following YAML syntax: |
| 85 | + |
| 86 | +```yml |
| 87 | +# Nr. of Columns |
| 88 | +cols: 4 |
| 89 | +# Nr. of Rows |
| 90 | +rows: 7 |
| 91 | +# Tile size (Grid cell size) |
| 92 | +tile_size: 64 |
| 93 | +# Canvas margin (optional) |
| 94 | +margin: 16 |
| 95 | +# Canvas watermark (optional) |
| 96 | +watermark: Draft |
| 97 | +# Canvas background color (optional) |
| 98 | +bg_color: "#ffffff" |
| 99 | +# List of used tileset |
| 100 | +atlas_list: |
| 101 | + - ../examples/aws_tileset.yml |
| 102 | + - ../examples/links_tileset.yml |
| 103 | +# Tiles mapping (associate an index to each tile) |
| 104 | +mapping: |
| 105 | + 1: aws_lambda |
| 106 | + 2: aws_elastic_container_service |
| 107 | + 3: aws_api_gateway |
| 108 | + 4: aws_rds_mysql_instance |
| 109 | + 5: aws_simple_storage_service_s3 |
| 110 | + 6: aws_elasticache_for_redis |
| 111 | + 10: link_vertical |
| 112 | + 11: link_vertical_arrow_up |
| 113 | + 20: link_cross_arrow_left_up_down |
| 114 | + 30: link_horizontal |
| 115 | + 40: link_tee_right_arrow_up_down |
| 116 | +# Static map layout |
| 117 | +layout: > |
| 118 | + 0,5,0,0 |
| 119 | + 4,20,30,2 |
| 120 | + 0,6,0,11 |
| 121 | + 0,0,0,10 |
| 122 | + 0,1,0,10 |
| 123 | + 0,40,30,3 |
| 124 | + 0,1,0,0,0 |
| 125 | +``` |
| 126 | +
|
| 127 | +👉 [examples/tilemap_demo_1.yml](./examples/tilemap_demo_1.yml). |
| 128 | +
|
| 129 | +Then execute the _'render'_ command: |
| 130 | +
|
| 131 | +```sh |
| 132 | +tiles render ./examples/tilemap_demo_1.yml > ./examples/tilemap_demo_1.png |
| 133 | +``` |
| 134 | + |
| 135 | +output: |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | +# Installation Steps |
| 140 | + |
| 141 | +To build the binaries by yourself, assuming that you have Go installed, you need [GoReleaser](https://goreleaser.com/intro/). |
| 142 | + |
| 143 | +Here the steps: |
| 144 | + |
| 145 | +### Grab the source code |
| 146 | + |
| 147 | +```bash |
| 148 | +git clone https://github.com/lucasepe/tiles.git |
| 149 | +``` |
| 150 | + |
| 151 | +### Change dir to the tool folder |
| 152 | + |
| 153 | +```bash |
| 154 | +cd tiles/cli |
| 155 | +``` |
| 156 | + |
| 157 | +### Run GoReleaser |
| 158 | + |
| 159 | +```bash |
| 160 | +goreleaser --rm-dist --snapshot --skip-publish |
| 161 | +``` |
| 162 | + |
| 163 | +you will found the binaries for: |
| 164 | + |
| 165 | +- MacOS into the folder _dist/tiles_darwin_amd64/_ |
| 166 | +- Linux into the folder _dist/tiles_linux_amd64/_ |
| 167 | +- Windows into the folder _dist/tiles_windows_amd64/_ |
| 168 | + |
| 169 | +## Ready-To-Use Releases |
| 170 | + |
| 171 | +If you don't want to compile the sourcecode yourself, [Here you can find the tool already compiled](https://github.com/lucasepe/tiles/releases/latest) for: |
| 172 | + |
| 173 | +- MacOS |
| 174 | +- Linux |
| 175 | +- Windows |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +# CHANGE LOG |
| 180 | + |
| 181 | +👉 [Record of all notable changes made to a project](./CHANGELOG.md) |
0 commit comments