Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
IsometricProjection.h
Go to the documentation of this file.
1/*
2 * IsometricProjection.h - Isometric coordinate transformation utilities
3 *
4 * TILED ISOMETRIC COORDINATE SYSTEM:
5 * ----------------------------------
6 * Tiled stores object positions in TMJ files using isometric pixel coordinates
7 * where BOTH X and Y are measured in tileHeight units along isometric axes.
8 *
9 * TMJ to World conversion:
10 * tileX = tmjPixelX / tileHeight
11 * tileY = tmjPixelY / tileHeight
12 * worldX = (tileX - tileY) * (tileWidth / 2)
13 * worldY = (tileX + tileY) * (tileHeight / 2)
14 *
15 * See IsometricProjection.cpp for detailed documentation and examples.
16 */
17
18#pragma once
19#include "../../vector.h" // Use engine's Vector class
20
21namespace Olympe {
22namespace Tiled {
23
25 {
26 public:
27 // Convert tile coordinates to screen coordinates (isometric projection)
28 static Vector WorldToIso(float worldX, float worldY, int tileWidth, int tileHeight,
29 int startX = 0, int startY = 0, float offsetX = 0.0f, float offsetY = 0.0f,
30 float globalOffsetX = 0.0f, float globalOffsetY = 0.0f);
31
32 // Convert screen coordinates to tile coordinates (inverse isometric)
33 static Vector IsoToWorld(float isoX, float isoY, int tileWidth, int tileHeight,
34 int startX = 0, int startY = 0, float offsetX = 0.0f, float offsetY = 0.0f,
35 float globalOffsetX = 0.0f, float globalOffsetY = 0.0f);
36
37 // Get tile at screen position
38 static void ScreenToTile(float screenX, float screenY, int tileWidth, int tileHeight,
39 int& outTileX, int& outTileY);
40
41 // Get screen position of tile corner
42 static Vector TileToScreen(int tileX, int tileY, int tileWidth, int tileHeight);
43
44 // Calculate Tiled's screen origin (for reference, not used in world coords)
45 static void CalculateTMJOrigin(int minTileX, int minTileY, int maxTileX, int maxTileY,
46 int tileWidth, int tileHeight,
47 float& outOriginX, float& outOriginY);
48 };
49
50} // namespace Tiled
51} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
static Vector WorldToIso(float worldX, float worldY, int tileWidth, int tileHeight, int startX=0, int startY=0, float offsetX=0.0f, float offsetY=0.0f, float globalOffsetX=0.0f, float globalOffsetY=0.0f)
static void ScreenToTile(float screenX, float screenY, int tileWidth, int tileHeight, int &outTileX, int &outTileY)
static Vector IsoToWorld(float isoX, float isoY, int tileWidth, int tileHeight, int startX=0, int startY=0, float offsetX=0.0f, float offsetY=0.0f, float globalOffsetX=0.0f, float globalOffsetY=0.0f)
static Vector TileToScreen(int tileX, int tileY, int tileWidth, int tileHeight)
static void CalculateTMJOrigin(int minTileX, int minTileY, int maxTileX, int maxTileY, int tileWidth, int tileHeight, float &outOriginX, float &outOriginY)