mirror of
https://github.com/raysan5/raylib.git
synced 2026-01-09 13:08:42 +01:00
Update models_first_person_maze.c
This commit is contained in:
@ -83,10 +83,14 @@ int main(void)
|
||||
// Check map collisions using image data and player position against surrounding cells only
|
||||
for (int y = playerCellY - 1; y <= playerCellY + 1; y++)
|
||||
{
|
||||
if (y < 0 || y >= cubicmap.height) continue;
|
||||
// Avoid map accessing out of bounds
|
||||
if ((y < 0) || (y >= cubicmap.height)) continue;
|
||||
|
||||
for (int x = playerCellX - 1; x <= playerCellX + 1; x++)
|
||||
{
|
||||
if (x < 0 || x >= cubicmap.width) continue;
|
||||
// Avoid map accessing out of bounds
|
||||
if ((x < 0) || (x >= cubicmap.width)) continue;
|
||||
|
||||
if ((mapPixels[y*cubicmap.width + x].r == 255) && // Collision: white pixel, only check R channel
|
||||
(CheckCollisionCircleRec(playerPos, playerRadius,
|
||||
(Rectangle){ mapPosition.x - 0.5f + x*1.0f, mapPosition.z - 0.5f + y*1.0f, 1.0f, 1.0f })))
|
||||
|
||||
Reference in New Issue
Block a user