I'm unsure how your engine works, but the best way I can think of is either a collision box that prevents the player from getting up in the corner, but the enemies can still move back and fourth, OR have the top of the screen shove the player back a bit if they get too close.