Discuss Scratch

coder9902htm4a0
Scratcher
51 posts

How do i make walls that sprites cant go through

So, yeah… anyone know how to make walls that sprites can't go through?

Check out Kirby's adventures with Spinni! By me!
when green flag clicked
if <(giratina) = [awesome]>then
say [Use shadow force!] for (2) secs
wait until <Giratina uses shadow force>
add [Knocked out Acreus] to [Pokemon Victories]
end
do victory dance
Pinkypinky33
Scratcher
30 posts

How do i make walls that sprites cant go through

coder9902htm4a0 wrote:

So, yeah… anyone know how to make walls that sprites can't go through?
I don't but I would like to know also!


foxfan
Scratcher
3 posts

How do i make walls that sprites cant go through

Yup i would also like to know this… I have been trying to work it out with scripts, without luck so far… If anyone knows how to do this that would be great to know! If I figure anything out I will post here!
dracae
Scratcher
1000+ posts

How do i make walls that sprites cant go through

Well, as always, posting what you have so far would definitely help. A basic solution to this is as follows:

This is mostly for 2-D top view games, so a description of your game (or better yet, a link) would lead to a more optimized answer.
Hope I helped!

Last edited by dracae (May 30, 2013 02:38:57)


Failord
Scratcher
1000+ posts

How do i make walls that sprites cant go through

If you want to get advanced, try this.

It guarantees a collision if you do it right.

Last edited by Failord (May 31, 2013 17:27:55)


Thanks for the ride, Scratch Team and community! Unfortunately, the time has come for me to move on from Scratch, so I'll no longer be using the forums. Thanks again, and farewell!
Invisible text! This will show you if a profile I claim to be mine IS mine. Just remember to visit the profile and see if I confirmed in the comments.
For old time's sake, see the revolutionary Laser Battle 2.0! Also see Unstoppable Game!

And no, the evil kumquats didn't alter my signature…
mwiedmann
Scratcher
100+ posts

How do i make walls that sprites cant go through

Here is an example you may like. Very simple. Uses variables to store your old location and sends you back there if there is a wall collision.

Wall collision example

7734f
Scratcher
500+ posts

How do i make walls that sprites cant go through

Here's an example on how to do this.

ATC1234
Scratcher
2 posts

How do i make walls that sprites cant go through

I REALLY NEED TO KNOW HOW TO MAKE WALLS SPRITES CANT GO THROUGH!!
MCAnimator3D
Scratcher
500+ posts

How do i make walls that sprites cant go through

If you are doing a scroll game with the variable “Scroll X,” you just make it so when the player touches the color, you add or subtract the same amount of Scroll X to the player thus preventing the player from going through walls. If it's just a simple "change x by " game, you pretty much do the same thing, but instead of adding/subtracting the Scroll, you do that to the x position of the player.


scratch
pndaJ
Scratcher
6 posts

How do i make walls that sprites cant go through

how do i make walls sprite can go on top of but cant go through
pndaJ
Scratcher
6 posts

How do i make walls that sprites cant go through

what i mean is if when touching the coler they dont move then even if the sprite is on top of the wall it wont move
ppfppfppf
Scratcher
1 post

How do i make walls that sprites cant go through

I think that the sprite has to test if it will hit the wall beforehand instead of moving back to a previous position when it touches one. I've done two tests.

Testing beforehand

not testing beforehand

So, use variables or lists to describe the walls' positions instead. Not sure how easy it would be to make a full scale game using that technique though.
AM-5573
Scratcher
100+ posts

How do i make walls that sprites cant go through

when green flag clicked
forever

if <touching [Wall Sprite v]?> then

point in direction (Whatever v)
end

Sorry if the blocks didn't turn out quite right…I'm new to this forum!

Evil kumquats? Ha! My signature was eaten by a pineapple.
AM-5573
Scratcher
100+ posts

How do i make walls that sprites cant go through

AM-5573 wrote:

when green flag clicked
forever

if <touching [Wall Sprite v]?> then

point in direction (Whatever v)
end

Sorry if the blocks didn't turn out quite right…I'm new to this forum!

Okay good it worked. This is how I would do it: Let me know how it works.

Evil kumquats? Ha! My signature was eaten by a pineapple.
TheCorruptedGamer
Scratcher
1 post

How do i make walls that sprites cant go through

http://scratch.mit.edu/projects/21943846 That is the link to my game. I have made it so that i can go on top of the brown floors and stairs as you can see. The walls on the side of the stairs are grey and i want to make it so that my sprite doesn't go THROUGH the stairs. Ty!
levtey
Scratcher
100+ posts

How do i make walls that sprites cant go through

when green flag clicked
forever

if <key [up arrow v] pressed?> then

change y by (5)
if <touching color [wall color]?> then

change y by (-5)
end
end
end
And repeat that for the 4 directions.
Kenichi10B
Scratcher
74 posts

How do i make walls that sprites cant go through

I'm making a platformer game right now (with velocity), would you like me to give you a link when I'm done so you can copy the movement system?
fezzinate
Scratcher
100+ posts

How do i make walls that sprites cant go through

Just today I made a project that explains how to do platformer collision handling

Check out the project here. Click “see inside” to see my comments that explains everything.
http://scratch.mit.edu/projects/22120949/

BobbyTurner
New to Scratch
2 posts

How do i make walls that sprites cant go through

@dracae it works, thanks.
LordDominayte
Scratcher
13 posts

How do i make walls that sprites cant go through

I usually do
if <touching [WallSprite v]?> then

set [x v] to ([x position v] of [PlayerSprite v])
repeat until <not <touching [WallSprite v]?>>

set x to (x)
end
end

But of course that would require you using a sprite. You could just use this for a backdrop-based platformer though:

if <touching color [WallColor v]?> then

set [x v] to ([x position v] of [PlayerSprite v])
repeat until <not <touching [WallSprite v]?>>

set x to (x)
end
end

Powered by DjangoBB