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

#1 2013-03-16 20:57:24

Cookman
Scratcher
Registered: 2012-11-24
Posts: 3

Going Through Walls

How can I stop my sprite from going through walls?

Offline

 

#2 2013-03-16 21:09:16

Harald
New Scratcher
Registered: 2013-03-05
Posts: 34

Re: Going Through Walls

when gf clicked
forever
if <not <touching [wall v]?>>
move around...

Offline

 

#3 2013-03-20 14:41:13

D-Man9293
Scratcher
Registered: 2012-12-17
Posts: 56

Re: Going Through Walls

Harald wrote:

when gf clicked
forever
if <not <touching [wall v]?>>
move around...

I don't think that would work. Try this.

when gf clicked
forever
   if <not> touching [wall v]
   if arrow keys pressed
   move _____ steps
end


Check out my signups for the game show  Scratch Island Survival!

Offline

 

#4 2013-03-21 21:56:24

KrIsMa
Scratcher
Registered: 2011-09-20
Posts: 500+

Re: Going Through Walls

Harald wrote:

when gf clicked
forever
if <not <touching [wall v]?>>
move around...

Sorry, that will not work, because of the sprite the script is nested in were to touch a wall, the sprite would never be able to move anymore.


http://blocks.scratchr.org/API.php?user=KrIsMa&amp;action=onlineStatus&amp;online=http://i49.tinypic.com/2pzic0m.png&amp;offline=http://i49.tinypic.com/r7p10n.png
The Scratch Team (and fellow scratchers!) is/are so nice!!!

Offline

 

#5 2013-03-22 02:34:14

parent2nj
New Scratcher
Registered: 2012-10-21
Posts: 9

Re: Going Through Walls

I was just looking into this very thing and found the 'Wall Sensors' wiki article about this.  Maybe it'll help you.

Offline

 

#6 2013-03-22 10:08:54

newnewfew
Scratcher
Registered: 2013-02-23
Posts: 68

Re: Going Through Walls

when gf clicked
forever if <touching [wall]?>
 rotate [180] degrees
 move 10 steps
end


It's contest time!
http://scratch.mit.edu/projects/newnewfew/3218957

Offline

 

#7 2013-03-23 12:43:58

newnewfew
Scratcher
Registered: 2013-02-23
Posts: 68

Re: Going Through Walls

Hope that helps


It's contest time!
http://scratch.mit.edu/projects/newnewfew/3218957

Offline

 

#8 2013-03-23 19:33:08

xlk
Scratcher
Registered: 2013-03-18
Posts: 57

Re: Going Through Walls

newnewfew wrote:

when gf clicked
forever if <touching [wall]?>
 rotate [180] degrees
 move 10 steps
end

Problem, that would make it go back and forth 10 pixels and never come out.
This fixes it

when gf clicked
if <touching [wall]?>
 rotate [180] degrees
 forever if <touching [wall]?>
   move 10 steps
 rotate (180) degrees
end

Offline

 

#9 2013-03-23 19:40:34

xlk
Scratcher
Registered: 2013-03-18
Posts: 57

Re: Going Through Walls

Sorry, meant this:

when gf clicked
if <touching [wall]?>
 rotate [180] degrees
 forever if <touching [wall]?>
   move 10 steps
  end
 rotate (180) degrees
end
sorry again, first time using these blocks on posts...

Offline

 

#10 2013-03-26 15:00:45

Cookman
Scratcher
Registered: 2012-11-24
Posts: 3

Re: Going Through Walls

when gf clicked
say [Thanks for the help!]

Last edited by Cookman (2013-03-26 15:03:26)

Offline

 

Board footer