Discuss Scratch

link8304
Scratcher
500+ posts

How do I make boundaries?

So, I like playing other people's platformers and whatnot, but in the three years I've been on Scratch I still don't know how to make any sort of boundaries without color coding the walls and hurting people's eyes. Like, what if I wanted to, say, make a character unable to move past a wall, but instead have them move around it/jump over it? Please, I'd really like to learn how to do this. Thanks in advance for any help you contribute!

(Also, I know I could probably just use a Platformer Engine, but I prefer to start from “Scratch” and thus a blank project.)


~ Link8304
asivi
Scratcher
1000+ posts

How do I make boundaries?

For squared horizontal or vertical boundaries it is pretty easy, all that you must to do is to check if x and y coordinates of your character plus its size(pixels from its center) are in a range in correspondence with a wall.
If your platformer is not a pen only one, you can do use of Sprite's detection.
_Lillion_
Scratcher
500+ posts

How do I make boundaries?

Draw your boundry area and make a script like this:
when green flag clicked
forever
if <touching color [boundry colour] ?> then
...
end
end

Last edited by _Lillion_ (Jan. 7, 2018 03:30:51)

matthewparkerstas
Scratcher
65 posts

How do I make boundaries?

here's an example:
when [right arrow v] key pressed
change x by (2)
if <touching [boundary v] ?> then
change x by (-2)
end
link8304
Scratcher
500+ posts

How do I make boundaries?

Thanks for your help, guys! The solutions work pretty well. I'm closing this thread to avoid any unnecessary replies.

Powered by DjangoBB