diff options
Diffstat (limited to 'src/floor.c')
| -rw-r--r-- | src/floor.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/floor.c b/src/floor.c index 22b2718..91dcf86 100644 --- a/src/floor.c +++ b/src/floor.c @@ -9,6 +9,7 @@ Tile *SE_CreateTile(TileLayer *layer, TilesetTile *tilesetTile) { tile->id = layer->tileCount; tile->tilesetTile = tilesetTile; tile->position = (Vector2){0.0f, 0.0f}; + tile->rotation = 0.0f; layer->tiles[layer->tileCount] = tile; layer->tileCount++; @@ -119,6 +120,7 @@ void SE_UpdateTileFloor(EditorState *state, TileFloor *floor, tile->position = pos; } + tile->rotation = state->tileRotation; tile->tilesetTile = state->activeTilesetTile; } @@ -147,7 +149,18 @@ void SE_DrawTileFloor(TileFloor *floor, EditorState *state, Camera2D *camera) { tile->position.y * camera->zoom, camera->zoom, camera->zoom}; - DrawTexturePro(tile->tilesetTile->texture, s, d, (Vector2){0, 0}, 0.0f, + Vector2 o = {0, 0}; + + if (tile->rotation == 90.0f) { + o.y = d.height; + } else if (tile->rotation == 180.0f) { + o.x = d.width; + o.y = d.height; + } else if (tile->rotation == 270.0f) { + o.x = d.width; + } + + DrawTexturePro(tile->tilesetTile->texture, s, d, o, tile->rotation, WHITE); } } @@ -158,8 +171,11 @@ void SE_DrawTileFloor(TileFloor *floor, EditorState *state, Camera2D *camera) { Rectangle s = {0, 0, TILE_WIDTH, TILE_HEIGHT}; Rectangle d = {mousePos.x, mousePos.y, camera->zoom / 2.0f, camera->zoom / 2.0f}; - DrawTexturePro(state->activeTilesetTile->texture, s, d, (Vector2){0, 0}, - 0.0f, WHITE); + + Vector2 o = {d.width / 2.0f, d.height / 2.0f}; + + DrawTexturePro(state->activeTilesetTile->texture, s, d, o, + state->tileRotation, WHITE); } } |
