Hey guys!
I have a level, player and enemy. I currently use this to keep the player inside of the level.
moveBy(xSpeed, ySpeed, ["level"]);
This keeps the player inside of the level (which is generated with OGMO)
When the player hits an enemy, I have the player ‘bumping’ away from the enemy to simulate getting struck. The problem I have, and you may have guessed, is when the player is bumped, if the player is jumping or near the edge of the level, the enemy is able to bump the player outside of the level.
I temporarily fixed this by adding all sorts of if(collide(“level” blah blah)); and it just got really confusing… So I was wondering if there is a cure all I could do in a few lines of code, to basically say, if the player is not within the confines of the level, move them to within the level.
Something like that. Thanks guys!