Last active
November 9, 2020 10:55
-
-
Save Saafan/94225a318fad4fa1e11371f77ec633fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vec2 CharacterPoints[4]; | |
void UpdateCollisionPoints() | |
{ | |
//The 5s below is just a small buffer, | |
//Change them accordingly | |
CharacterPoints[0] = Vec2(posX - 5, posY - 5); | |
CharacterPoints[1] = Vec2(posX + character_Width + 5, posY - 5); | |
CharacterPoints[2] = Vec2(posX - 5, PosY + character_Height + 5); | |
CharacterPoints[3] = Vec2(posX + character_Width - 5, posY + chrachter_Height + 5); | |
} | |
bool CheckCollision() | |
{ | |
for (size_t i = 0; i < num_of_lanes; i++) | |
{ | |
for (size_t i = 0; i < 4 /* Change the Number accordingly */; i++) | |
{ | |
if (lane.x < CharacterPoints[i].x && lane.x + lane_Segment_Width > CharacterPoints[i].x) | |
{ | |
if (lane.y < CharacterPoints[i].y && lane.y + lane_Segment_Heigt > CharacterPoints[i].y) | |
{ | |
return true; //return that It'll Collide | |
} | |
} | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment