How to make a wall?

Well, i need to place something like a wall. A block my Character can't walk through. But i don't know how to do this.
Can someone explain to me, how to do this?

Make a sprite for the wall. Have the character/hitbox sprite detect if its touching the wall sprite and move back if it is.

Hello,
Here is a coded version of @snapenilk's reply:
untitled script pic (1)
Just trying to be helpful!

No, only move back if touching the wall.

I do not get it.

image

If the wall is thinner than the velocity, the sprite will go to the other side of the wall.
This script should prevent that:
repeat (velocity) {
move (1) steps
if <touching [wall v]> {
move (-1) steps
stop [this script v]
}
}

Well, your code will make the sprite move 1 step to the left or back. Whereas, my code will keep the sprite in the same position, i.e. it will not let the sprite move.

Do you know how noise cancelling headphones work? It takes the audio that is coming in and plays the same audio with opposing wavelengths. Your code not only plays the audio with opposing wavelengths, but also plays the audio that is coming in, so the 2 cancel each other out before it even gets to your ears, and the original audio that's actually coming from outside goes into your ears anyways. If you still have no idea what I mean, test out yours and @snapenilk's code seperately, and compare.

hope this helps!

And if the sprite is touching the wall, we don't want to keep the sprite there.

Unhelpful. I do not get what you mean.

And why?

The purpose of the wall is to not let the sprite go through it.

haha, just kidding.

Every action has it's equal and opposite reaction, but your code gives the action more "action" than it's reaction, and it'll just go through the wall. hope that's a bit more helpful!

Uh, okay?

If the sprite touches the wall and doesn't move off of it, then the sprite could go through the wall. If the sprite goes off of the wall every time it touches the wall, then it can't go through the wall.

This is how you make a wall:

If the sprite touches the wall from the right, it will move -10 steps until it is left of the wall.

Ok i know