diff options
-rw-r--r-- | src/tiled.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/tiled.c b/src/tiled.c index d525027..b90aea7 100644 --- a/src/tiled.c +++ b/src/tiled.c @@ -6,10 +6,10 @@ int alpha =0; void updateCamera(Tiled * tiled) { - if (IsKeyDown(KEY_UP)) tiled->offset.y += 4.0f / tiled->zoom; - if (IsKeyDown(KEY_DOWN)) tiled->offset.y -= 4.0f / tiled->zoom; - if (IsKeyDown(KEY_RIGHT)) tiled->offset.x -= 4.0f / tiled->zoom; - if (IsKeyDown(KEY_LEFT)) tiled->offset.x += 4.0f / tiled->zoom; + if (IsKeyDown(KEY_UP)) tiled->offset.y += 16.0f / tiled->zoom; + if (IsKeyDown(KEY_DOWN)) tiled->offset.y -= 16.0f / tiled->zoom; + if (IsKeyDown(KEY_RIGHT)) tiled->offset.x -= 16.0f / tiled->zoom; + if (IsKeyDown(KEY_LEFT)) tiled->offset.x += 16.0f / tiled->zoom; if (IsKeyDown(KEY_W)) tiled->zoom += tiled->zoom * 0.01f; if (IsKeyDown(KEY_S)) tiled->zoom -= tiled->zoom * 0.01f; @@ -19,6 +19,9 @@ void updateCamera(Tiled * tiled) { tiled->renderOffset.x = tiled->offset.x - tiled->chunkOffset[0]*tiled->tiledMap.chunkWidth; tiled->renderOffset.y = tiled->offset.y - tiled->chunkOffset[1]*tiled->tiledMap.chunkHeight; + + // TODO only do this when chunk offset has changed + // TODO unload chunks when they are no longer visible redrawTiledMap(*tiled); } |