Is there a way to make something stop moving when it hits an edge of the screen?

53 views
Skip to first unread message

grootnb...@gmail.com

unread,
Apr 25, 2021, 7:48:06 PMApr 25
to PuzzleScript
In a game I'm working on, the player can do something that lets them move left or right until they bump into a wall. That's easy enough, but how do I make them stop moving when they bump into the edge of the screen? The only thing I can think of is to make a completely black object and surround the game maps with it. But is there some kind of variable that I can use to make something happen when the player bumps into the edge of the screen?

Stephen Lavelle

unread,
Apr 25, 2021, 8:20:13 PMApr 25
to grootnb...@gmail.com, PuzzleScript
in general yeah surrounding the level with a wall is the best way

Am Mo., 26. Apr. 2021 um 01:48 Uhr schrieb grootnb...@gmail.com <grootnb...@gmail.com>:
In a game I'm working on, the player can do something that lets them move left or right until they bump into a wall. That's easy enough, but how do I make them stop moving when they bump into the edge of the screen? The only thing I can think of is to make a completely black object and surround the game maps with it. But is there some kind of variable that I can use to make something happen when the player bumps into the edge of the screen?

--
You received this message because you are subscribed to the Google Groups "PuzzleScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puzzlescript...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/puzzlescript/6b24522c-891e-4925-a8a3-2dc35063068en%40googlegroups.com.

Pedro PSI

unread,
Apr 26, 2021, 9:52:20 AMApr 26
to PuzzleScript
Surrounding the level with walls is probably the easiest way, but here's a small example in case you need to actually detect the screen edges.

The idea is to place markers everywhere, then remove them where there's an adjacent background tile in a particular direction. The markers survive only at the edges, and can be used to create a "bump". The markers could be hidden with a transparent colour as needed. Voila!

Cheers,
Pedro PSI

grootnb...@gmail.com

unread,
Apr 26, 2021, 11:36:12 PMApr 26
to PuzzleScript
Thanks for the tip, Pedro! I'll try that out. And if it doesn't work right, I'll just use surrounding the screen.
Reply all
Reply to author
Forward
0 new messages