How to keep the player inside the screen in WoofJS
2D Game Design with WoofJS
🕑 This lesson will take about 5 minutes
In this lesson, you will learn how to make sure the player can’t go past any of the four edges of the screen and disappear from the game in WoofJS, as show below. When the player attempts to move outside the game world, the code will stop them from moving any further and keep them in their current position unless they move away from the edge of the screen.
Go to woofjs.com, create a new project and use the code below: