This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-28 16:10:13

carloszhu
New Scratcher
Registered: 2013-01-28
Posts: 5

Anyone know how to make characters bounce off walls? Thanks beforehand

Hello All!
I am making Pacman and I am about done with it, yet I just need to tweak one minor detail. I have walls in my game but I can't seem to find the right script to make the pacman stop when it gets to the wall. ie. it passes through the wall. Please note that one side of my wall is the edge, yet one side is not part of the edge.

Offline

 

#2 2013-01-28 16:56:12

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Anyone know how to make characters bounce off walls? Thanks beforehand

Well, i cant really offer a solution because I am wondering about the same thing, you see, i too am going to make a pacman game, and i need to know this info.

I can guess though, and my guess is that you either use the

 
touching [wall v]
or
 
color [#00FF00] touching [#00FF00]
or you use a completely ghosted sprite that has a
if < touching [wall v]>
end
I hope that helps or a least offers some options,

CAA14

P.S. if any work, please tell me which ones so i can know which is better.  wink

Offline

 

#3 2013-01-28 17:09:05

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Anyone know how to make characters bounce off walls? Thanks beforehand

Another question,

How did you make the pellets?

That's my biggest question right now,

Regards,

CAA14

Offline

 

#4 2013-01-29 01:37:43

lavaghost123
New Scratcher
Registered: 2013-01-13
Posts: 4

Re: Anyone know how to make characters bounce off walls? Thanks beforehand

Say your character moves 10 steps if the D key is pressed, put another IF block inside that IF; saying IF touching colour (of wall) move -10 steps etc. Hope this helped :-)

Offline

 

#5 2013-01-29 15:56:37

carloszhu
New Scratcher
Registered: 2013-01-28
Posts: 5

Re: Anyone know how to make characters bounce off walls? Thanks beforehand

Thanks. Yeah, I tried that and it helps.

To CAA14, sorry I couldn't get back to you earlier, I was in school. By the pellets, I just painted the sprites black and I got the maze online  sad . I think only your second option works since I tried the others.

Offline

 

#6 2013-01-29 21:14:04

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Anyone know how to make characters bounce off walls? Thanks beforehand

Ok, that's good to know.
Glad i could help.  smile
You did apply the "if touching wall" script to pacman right?
If so, that should work as long as the wall is a separate sprite... But if you got the maze as a whole sprite, you may want to make the wall lines a distinct color and use the color approach or try to recreate the wall in it and make it a separate sprite and use the "if touching" approach.

Once you get it working, please let me know... I'd like to see your handiwork.  smile
BTW, no problem, you had no time limit to respond.  smile
Regards,


CAA14

Offline

 

Board footer