Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ^^^ all character movement is redundant for this post but is is above this comment
- std::vector<scene::ISceneNode *> objects; // A vector containing all of the different blocks
- objects.push_back(block); // I add the objects in an array, for later access and easability
- // after all character movement, check if player rect intersects with any block
- for(int i = 0; i < objects.size(); i++) { // go through all the block objects
- if(player->getTransformedBoundingBox().intersectsWithBox(objects[i]->getTransformedBoundingBox())) { // if they intersect, do the following
- falling = false;
- can_jump = true;
- walk = false;
- player->setPosition(last_pos); // makes the character stuck, since it always collides with floor
- break;
- } else {
- falling = true;
- can_jump = false;
- walk = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement