mirror of https://github.com/raysan5/raylib
Update core_2d_camera_platformer.c
This commit is contained in:
parent
ff1eeafb95
commit
40f3df5b86
|
@ -135,6 +135,8 @@ int main(void)
|
|||
|
||||
Rectangle playerRect = { player.position.x - 20, player.position.y - 40, 40, 40 };
|
||||
DrawRectangleRec(playerRect, RED);
|
||||
|
||||
DrawCircle(player.position.x, player.position.y, 5, GOLD);
|
||||
|
||||
EndMode2D();
|
||||
|
||||
|
@ -168,7 +170,7 @@ void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float d
|
|||
player->canJump = false;
|
||||
}
|
||||
|
||||
int hitObstacle = 0;
|
||||
bool hitObstacle = false;
|
||||
for (int i = 0; i < envItemsLength; i++)
|
||||
{
|
||||
EnvItem *ei = envItems + i;
|
||||
|
@ -179,9 +181,10 @@ void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float d
|
|||
ei->rect.y >= p->y &&
|
||||
ei->rect.y <= p->y + player->speed*delta)
|
||||
{
|
||||
hitObstacle = 1;
|
||||
hitObstacle = true;
|
||||
player->speed = 0.0f;
|
||||
p->y = ei->rect.y;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue