Day 31 complete.

This commit is contained in:
igor
2026-04-10 02:06:25 -07:00
parent a2985c20ef
commit 1635bebb5d
3 changed files with 33 additions and 30 deletions
+24 -22
View File
@@ -149,16 +149,16 @@ static cannonical_position GetCannonicalPosition(world *World,
X = Pos.X - World->UpperLeftX;
Y = Pos.Y - World->UpperLeftY;
Result.TileX = FloorF32toS32(X / World->TileWidth);
Result.TileY = FloorF32toS32(Y / World->TileHeight);
Result.TileX = FloorF32toS32(X / (F32)World->TileSideInPixels);
Result.TileY = FloorF32toS32(Y / (F32)World->TileSideInPixels);
Result.X = X - Result.TileX*World->TileWidth;
Result.Y = Y - Result.TileY*World->TileHeight;
Result.X = X - (F32)Result.TileX*(F32)World->TileSideInPixels;
Result.Y = Y - (F32)Result.TileY*(F32)World->TileSideInPixels;
ASSERT(Result.X >= 0);
ASSERT(Result.Y >= 0);
ASSERT(Result.X < World->TileWidth);
ASSERT(Result.Y < World->TileHeight);
ASSERT(Result.X < (F32)World->TileSideInPixels);
ASSERT(Result.Y < (F32)World->TileSideInPixels);
if(Result.TileX < 0) {
Result.TileX = World->CountX + Result.TileX;
@@ -271,14 +271,14 @@ void UpdateAndRender(thread_context *Thread, game_memory *Memory,
World.TileMapCountY = 2;
World.CountX = TILEMAP_COUNT_X;
World.CountY = TILEMAP_COUNT_Y;
World.UpperLeftX = 0.0f;
World.UpperLeftY = 0.0f;
World.TileWidth = 57.0f;
World.TileHeight = 57.0f;
World.TileSideInMeters = 1.4f;
World.TileSideInPixels = 60;
World.UpperLeftX = -((F32)World.TileSideInPixels / 2.0f);
World.UpperLeftY = 0.0f;
World.TileMaps = (tile_map *)TileMaps;
PlayerWidth = 0.75f * World.TileWidth;
PlayerHeight = World.TileHeight;
PlayerWidth = 0.75f * (F32)World.TileSideInPixels;
PlayerHeight = (F32)World.TileSideInPixels;
GameState = (game_state *)Memory->PermanentStorage;
if(!Memory->IsInitialized) {
@@ -323,10 +323,8 @@ void UpdateAndRender(thread_context *Thread, game_memory *Memory,
dPlayerX *= 200.0f;
dPlayerY *= 200.0f;
NewPlayerX = RoundF32toS32(GameState->PlayerX +
Input->dtForFrame*dPlayerX);
NewPlayerY = RoundF32toS32(GameState->PlayerY +
Input->dtForFrame*dPlayerY);
NewPlayerX = GameState->PlayerX + Input->dtForFrame*dPlayerX;
NewPlayerY = GameState->PlayerY + Input->dtForFrame*dPlayerY;
PlayerPos.TileMapX = GameState->PlayerTileMapX;
PlayerPos.TileMapY = GameState->PlayerTileMapY;
@@ -349,9 +347,11 @@ void UpdateAndRender(thread_context *Thread, game_memory *Memory,
GameState->PlayerTileMapX = CanPos.TileMapX;
GameState->PlayerTileMapY = CanPos.TileMapY;
GameState->PlayerX = World.UpperLeftX +
World.TileWidth*CanPos.TileX + CanPos.X;
(F32)World.TileSideInPixels * (F32)CanPos.TileX +
CanPos.X;
GameState->PlayerY = World.UpperLeftY +
World.TileHeight*CanPos.TileY + CanPos.Y;
(F32)World.TileSideInPixels * (F32)CanPos.TileY +
CanPos.Y;
}
}
}
@@ -368,10 +368,12 @@ void UpdateAndRender(thread_context *Thread, game_memory *Memory,
if(TileID) {
Gray = 1.0f;
}
MinX = World.UpperLeftX + (F32)(Column) * World.TileWidth;
MinY = World.UpperLeftY + (F32)(Row) * World.TileHeight;
MaxX = MinX + World.TileWidth;
MaxY = MinY + World.TileHeight;
MinX = World.UpperLeftX +
(F32)(Column) * (F32)World.TileSideInPixels;
MinY =
World.UpperLeftY + (F32)(Row) * (F32)World.TileSideInPixels;
MaxX = MinX + (F32)World.TileSideInPixels;
MaxY = MinY + (F32)World.TileSideInPixels;
DrawRectangle(Buffer, MinX, MinY, MaxX, MaxY, Gray, Gray, Gray);
}
}