Keeping Cube Buddy inside the Box

Harvey Limbo
Mar 22, 2021

--

For today’s article, I’ll be going over how I kept my Cube within bounds of the Game View. Our goal is to keep the cube is the following:

  1. Prevent Cube from moving past the top and bottom edges of the Game View.
  2. Apply screen wrapping where Cube teleports to the right side of the screen when moving past left edge of Game View and vice versa.

Note: These boundaries are based on hard-coded x and y values and may need to be updated based on target resolution when building the Game as an executable. The purpose of these code snippets is to see how to achieve an effect that is desirable for prototyping purposes:

Top and Bottom Bounds

Screen Wrapping

Thanks for reading!

--

--

Harvey Limbo
Harvey Limbo

No responses yet