Skip to content

Commit

Permalink
first commit!
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasepe committed Aug 27, 2020
0 parents commit f758e9d
Show file tree
Hide file tree
Showing 30 changed files with 19,813 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## Intellij
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/encodings.xml
.idea/**/compiler.xml
.idea/**/misc.xml
.idea/**/modules.xml
.idea/**/vcs.xml

## VSCode
.vscode/

## File-based project format:
*.iws
*.iml
.idea/

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.dat
*.DS_Store
go.sum

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Goreleaser builds
**/dist/**

icons/**
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.0] - 2020-08-28
- 🎉 First release!
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Luca Sepe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
181 changes: 181 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@

# **Tiles**

> Commandline tool that makes building tilesets and rendering static tilemaps super easy!
**Features**

- create your own tilesets _"libraries"_ (ready to reuse)
- inspect, list and extract tiles from tilesets
- define a tilemap using one or more tileset
- render a tilemap as PNG images
- eventually add a watermark to the tilemap

![](./banner.png)

### Overview

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.

The most efficient way to store the tile images is in an atlas or tileset

- all of the required tiles grouped together in a single image file

When it's time to draw a tile, only a small section of this bigger image is rendered on the grid.

#### Static square tilemaps

Square-based tilemaps are the most simple implementation for two perspectives:

- top-down (like many RPG's or strategy games)
- side-view (like platformers such as Super Mario Bros)
- architecture diagrams...why not!? 😏

# How to use **tiles**

## All available commands

```bash
tiles --help
```

## Generate a tileset

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:

```bash
tiles compose /path/to/png/images/
```

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:

```bash
tiles compose /path/to/png/images/ > my_tileset.yml
```

### Ready-To-Use tilesets

| Set | URL |
|:-----------------------|:---------------------------------------------------------|
| AWS Icons | [./examples/aws_tileset.yml](./examples/aws_tileset.yml) |
| Arrows and Connectors | [./examples/links_tileset.yml](./examples/links_tileset.yml) |


## Lists all tiles identifiers contained in the specified tilset

```bash
tiles list /path/to/my_tileset.yml
```

## Extracts the tile PNG with the specified identifier from the tileset

```bash
tiles pull --id aws_waf ../examples/aws_tileset.yml
```

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:

```bash
tiles pull --id aws_waf ../examples/aws_tileset.yml > aws_waf.png
```

## Rendering a static tilemap

The first step is to create the static tilemap using the following YAML syntax:

```yml
# Nr. of Columns
cols: 4
# Nr. of Rows
rows: 7
# Tile size (Grid cell size)
tile_size: 64
# Canvas margin (optional)
margin: 16
# Canvas watermark (optional)
watermark: Draft
# Canvas background color (optional)
bg_color: "#ffffff"
# List of used tileset
atlas_list:
- ../examples/aws_tileset.yml
- ../examples/links_tileset.yml
# Tiles mapping (associate an index to each tile)
mapping:
1: aws_lambda
2: aws_elastic_container_service
3: aws_api_gateway
4: aws_rds_mysql_instance
5: aws_simple_storage_service_s3
6: aws_elasticache_for_redis
10: link_vertical
11: link_vertical_arrow_up
20: link_cross_arrow_left_up_down
30: link_horizontal
40: link_tee_right_arrow_up_down
# Static map layout
layout: >
0,5,0,0
4,20,30,2
0,6,0,11
0,0,0,10
0,1,0,10
0,40,30,3
0,1,0,0,0
```

👉 [examples/tilemap_demo_1.yml](./examples/tilemap_demo_1.yml).

Then execute the _'render'_ command:

```sh
tiles render ./examples/tilemap_demo_1.yml > ./examples/tilemap_demo_1.png
```

output:

![](./examples/tilemap_demo_1.png)

# Installation Steps

To build the binaries by yourself, assuming that you have Go installed, you need [GoReleaser](https://goreleaser.com/intro/).

Here the steps:

### Grab the source code

```bash
git clone https://github.com/lucasepe/tiles.git
```

### Change dir to the tool folder

```bash
cd tiles/cli
```

### Run GoReleaser

```bash
goreleaser --rm-dist --snapshot --skip-publish
```

you will found the binaries for:

- MacOS into the folder _dist/tiles_darwin_amd64/_
- Linux into the folder _dist/tiles_linux_amd64/_
- Windows into the folder _dist/tiles_windows_amd64/_

## Ready-To-Use Releases

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:

- MacOS
- Linux
- Windows

---

# CHANGE LOG

👉 [Record of all notable changes made to a project](./CHANGELOG.md)
Binary file added banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f758e9d

Please sign in to comment.