https://github.com/robloach/raylib-tileson
Use Tiled maps in raylib, through Tileson.
https://github.com/robloach/raylib-tileson
Last synced: over 1 year ago
JSON representation
Use Tiled maps in raylib, through Tileson.
- Host: GitHub
- URL: https://github.com/robloach/raylib-tileson
- Owner: RobLoach
- License: bsd-2-clause
- Created: 2021-05-03T09:33:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-03T14:10:21.000Z (about 3 years ago)
- Last Synced: 2023-05-03T15:37:59.294Z (about 3 years ago)
- Language: C++
- Homepage:
- Size: 220 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# raylib-tileson
Use [Tiled](https://www.mapeditor.org) maps in [raylib](https://www.raylib.com/), through [Tileson](https://github.com/SSBMTonberry/tileson).

## Example
``` c
#include "raylib.h"
#define RAYLIB_TILESON_IMPLEMENTATION
#include "raylib-tileson.h"
int main(int argc, char* argv[]) {
InitWindow(800, 450, "[raylib-tileson] example");
SetTargetFPS(60);
// Load the map
Map map = LoadTiled("resources/desert.json");
while (!WindowShouldClose()) {
BeginDrawing();
{
ClearBackground(RAYWHITE);
// Draw the map
DrawTiled(map, 0, 0, WHITE);
}
EndDrawing();
}
// De-Initialization
UnloadMap(map);
CloseWindow();
return 0;
}
```
## Dependencies
- [raylib](https://www.raylib.com/) ~5.5
- C++17 or higher
## API
``` c
Map LoadTiled(const char* fileName);
Map LoadTiledFromMemory(const unsigned char *fileData, int dataSize, const char* baseDir);
bool IsTiledReady(Map map);
void DrawTiled(Map map, int posX, int posY, Color tint);
void UnloadMap(Map map);
```
## Alternatives
While *raylib-tileson* does compile and run from C, it requires compilation with C++17. Mixing C and C++ may not be preferable by all, so there could be a desire to use an alternative...
- [raylib-tmx](https://github.com/RobLoach/raylib-tmx)
- [raylib-tiled](https://github.com/RobLoach/raylib-tiled)
## Development
``` bash
mkdir build
cd build
cmake ..
make
./example/raylib-tileson-example
```
## License
*raylib-tileson* is licensed under the BSD 2-Clause License, see [LICENSE](LICENSE) for more information.