Hello guys,
I'm trying to validate
my article on collision detection by implementing all of the example code. I found something I'm pretty sure is a bug. Althogh not serious (especially for HH's case), I'd like to have my example code in the article correct and just want to confirm (in case I'm not missing something).
To be concrete, I'm taking about Day 50, handmade.cpp, method MovePlayer, excerpt starting at line 416:
1
2
3
4
5
6
7
8
9
10
11
12 | uint32 MinTileX = Minimum(OldPlayerP.AbsTileX, NewPlayerP.AbsTileX);
uint32 MinTileY = Minimum(OldPlayerP.AbsTileY, NewPlayerP.AbsTileY);
uint32 MaxTileX = Maximum(OldPlayerP.AbsTileX, NewPlayerP.AbsTileX);
uint32 MaxTileY = Maximum(OldPlayerP.AbsTileY, NewPlayerP.AbsTileY);
uint32 EntityTileWidth = CeilReal32ToInt32(Entity.High->Width / TileMap->TileSideInMeters);
uint32 EntityTileHeight = CeilReal32ToInt32(Entity.High->Height / TileMap->TileSideInMeters);
MinTileX -= EntityTileWidth;
MinTileY -= EntityTileHeight;
MaxTileX += EntityTileWidth;
MaxTileY += EntityTileHeight;
|
On the last 4 lines, we should be adding (ceiled) half of EntityTileWidth/EntityTileHeight to the MinTileX/MinTileY/MaxTileX/MaxTileY. Is that correct?