Scythe
SCYTHE is a lightweight, C#-based game engine focused on modifiability and rapid iteration using Raylib.
Header-only TMX loader for raylib written in portable C99
git clone https://github.com/luphi/raytmx.gitluphi/raytmxHeader-only raylib library for loading and drawing Tiled's TMX tilemap documents.
<properties> are not supported; they are merged into a single list of propertiesDefine the implementation before including raytmx.
#define RAYTMX_IMPLEMENTATION #include "raytmx.h"
Only do this in one file. In other source files, include the header without defining the implemntation.
Loading and unloading follows raylib's patterns.
TmxMap* LoadTMX(const char *fileName); void UnloadTMX(TmxMap *map);
Drawing also follows raylib's patterns.
void DrawTMX(const TmxMap *map, const Camera2D *camera, const Rectangle *viewport, int posX, int posY, Color tint);
void DrawTMXLayers(const TmxMap *map, const Camera2D *camera, const Rectangle *viewport, const TmxLayer *layers,
uint32_t layersLength, int posX, int posY, Color tint);
Animating a TMX is done by calling a specific function once per frame.
void AnimateTMX(TmxMap *map);
Collision checks also follow raylib's patterns.
bool CheckCollisionTMXObjects(TmxObject object1, TmxObject object2);
bool CheckCollisionTMXTileLayersRec(const TmxMap *map, const TmxLayer *layers, uint32_t layersLength, Rectangle rec,
TmxObject *outputObject);
bool CheckCollisionTMXTileLayersCircle(const TmxMap *map, const TmxLayer *layers, uint32_t layersLength, Vector2 center,
float radius, TmxObject *outputObject);
bool CheckCollisionTMXTileLayersPoint(const TmxMap *map, const TmxLayer *layers, uint32_t layersLength, Vector2 point,
TmxObject *outputObject);
bool CheckCollisionTMXTileLayersPolyPoly(const TmxMap *map, const TmxLayer *layers, uint32_t layersLength,
Vector2 *points, int pointCount, TmxObject *outputObject);
bool CheckCollisionTMXTileLayersPolyPolyEx(const TmxMap *map, const TmxLayer *layers, uint32_t layersLength,
Vector2 *points, int pointCount, Rectangle aabb, TmxObject *outputObject);
bool CheckCollisionTMXObjectGroupRec(TmxObjectGroup group, Rectangle rec, TmxObject *outputObject);
bool CheckCollisionTMXObjectGroupCircle(TmxObjectGroup group, Vector2 center, float radius, TmxObject *outputObject);
bool CheckCollisionTMXObjectGroupPoint(TmxObjectGroup group, Vector2 point, TmxObject *outputObject);
bool CheckCollisionTMXObjectGroupPoly(TmxObjectGroup group, Vector2 *points, int pointCount, TmxObject *outputObject);
bool CheckCollisionTMXObjectGroupPolyEx(TmxObjectGroup group, Vector2 *points, int pointCount, Rectangle aabb,
TmxObject *outputObject);
Although raytmx doesn't do anything that would be considered collision response, the objects collided with are provided as optional output variables, outputObject, to allow for it.
Example programs that use all of the above features are included.
A more minimal example program would look like:
#include <stddef.h> // Required for: NULL.
#include <stdlib.h> // Required for: EXIT_FAILURE, EXIT_SUCCESS.
#include "raylib.h"
#define RAYTMX_IMPLEMENTATION
#include "raytmx.h"
int main(void)
{
// Configure the window with a resolution and title. This example will also target 60 frames per second.
const int screenWidth = 1024;
const int screenHeight = 768;
const float panSpeed = 150.0f; // Pixels per second.
InitWindow(screenWidth, screenHeight, "raytmx example");
SetTargetFPS(60);
// Load the map from disk. If loading fails, NULL will be returned and details will be TraceLog()'d.
TmxMap *map = LoadTMX("example.tmx");
if (map == NULL)
{
TraceLog(LOG_ERROR, "Failed to load TMX \"example.tmx\"");
CloseWindow();
return EXIT_FAILURE;
}
// Create a camera that initially looks at the center of the map.
Camera2D camera = { 0 };
camera.target = (Vector2){ (float)(map->width*map->tileWidth)/2.0f, (float)(map->height*map->tileHeight)/2.0f };
camera.offset = (Vector2){ (float)screenWidth/2.0f, (float)screenHeight/2.0f };
camera.rotation = 0.0f;
camera.zoom = 6.0f;
while (!WindowShouldClose())
{
// Pan the camera based on which arrow key, if any, is pressed.
if (IsKeyDown(KEY_RIGHT)) camera.target.x += panSpeed*GetFrameTime();
if (IsKeyDown(KEY_LEFT)) camera.target.x -= panSpeed*GetFrameTime();
if (IsKeyDown(KEY_DOWN)) camera.target.y += panSpeed*GetFrameTime();
if (IsKeyDown(KEY_UP)) camera.target.y -= panSpeed*GetFrameTime();
BeginDrawing();
{
ClearBackground(BLACK);
BeginMode2D(camera);
{
AnimateTMX(map);
DrawTMX(map, &camera, NULL, 0, 0, WHITE);
}
EndMode2D();
}
EndDrawing();
}
UnloadTMX(map);
CloseWindow();
return EXIT_SUCCESS;
}
raytmx depends on hoxml for XML parsing and raylib for its graphical, file system, and time utilities.
more like this
SCYTHE is a lightweight, C#-based game engine focused on modifiability and rapid iteration using Raylib.
.Net 10 (.Net 8+) webassembly starter project using raylib-cs nuget 7.0.2 and raylib 5.5
search projects, people, and tags