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

#1 2010-06-04 04:11:42

mabbs123
Scratcher
Registered: 2010-04-20
Posts: 18

Walls

How do you make a sprite run into a wall instead of going straight through it?


...........I'm A Bubble.............

Offline

 

#2 2010-06-06 11:38:24

Greentabby55
Scratcher
Registered: 2010-05-04
Posts: 50

Re: Walls

<when green flag clicked>
<forever>
<if><touching[ Wall
<wait( 0.01 )secsc>
<end>
<end>

Offline

 

#3 2010-06-06 11:41:29

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Walls

You could use something like this:
http://scratch.mit.edu/projects/juststickman/1014254

Only look at the first script in the players unless you enjoy long laggy math.


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#4 2010-06-06 14:12:44

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Walls

Greentabbys script wouldn't do anything at all.

You can either do it the complicated way or simply have color sensors on the sprite and move -5/5 steps when it is touching a wall.

Offline

 

#5 2010-06-07 18:14:01

Subh
Scratcher
Registered: 2010-05-25
Posts: 100+

Re: Walls

if your walls are a separate sprite, then you can try my method

[blocks]<when green flag clicked>
<forever>
       <if> <touching[ [/blocks] Wall
[blocks]       <set{ x velocity }to( [/blocks] 0
[blocks]       <end>
<end>[/blocks]
('if you use x velocity)


[blocks]<when green flag clicked>
<forever>
       <if> <touching[ [/blocks] Wall
[blocks]
                 <repeat until><<  <not> <touching[ [/blocks] Wall [blocks] >>
<change{ <x position> }by( 1
                 <end>
       <end>
<end>[/blocks]

The second method has 1 problem. You have to make a way of this happening on both sides or When you go from the Right, its OK But when you go from the Left, it runs the wall over. Hope this helped  big_smile


http://wiki.scratch.mit.edu/skins/scratch/logo.png     I'M IN Scratch Wiki .... ARE YOU ????

Offline

 

Board footer