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

#1 2012-09-07 19:05:59

bird12345
New Scratcher
Registered: 2012-08-17
Posts: 10

How do you stop sprites going through fake walls?

Do you know ?

Offline

 

#2 2012-09-07 19:24:23

bird12345
New Scratcher
Registered: 2012-08-17
Posts: 10

Re: How do you stop sprites going through fake walls?

Using mouse

Offline

 

#3 2012-09-07 19:52:48

henley
Scratcher
Registered: 2008-06-21
Posts: 1000+

Re: How do you stop sprites going through fake walls?

What?


"I've worked so hard for you and you give me nothing in return. Do you need help... Or do I?"

Offline

 

#4 2012-09-07 20:19:19

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How do you stop sprites going through fake walls?

What are you asking?  Is the sprite following your mouse and you want to stop it from going through a sprite (or color)?


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2012-09-09 21:58:49

bird12345
New Scratcher
Registered: 2012-08-17
Posts: 10

Re: How do you stop sprites going through fake walls?

Yes but it is a background which I drew

Offline

 

#6 2012-09-09 22:10:09

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: How do you stop sprites going through fake walls?

Try the script below.  It won't be instantaneous (in fact, it will be rather slow), but if you want it sped up I can rewrite it to make it faster (using single frame)

when gf clicked
go to x:(0) y:(0)
forever
if<([abs v] of ((mouse x)-(x position))) > (4)>
if<((mouse x)-(x position)) > (0)>
change x by (4)
if<touching color [#000000]?>
change x by (-4)
end
else
change x by (-4)
if<touching color [#000000]?>
change x by (4)
end
end
end

if<([abs v] of ((mouse y)-(y position))) > (4)>
if<((mouse y)-(y position)) > (0)>
change y by (4)
if<touching color [#000000]?>
change y by (-4)
end
else
change y by (-4)
if<touching color [#000000]?>
change y by (4)
end
end
end


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#7 2012-09-10 04:35:51

taddl
Scratcher
Registered: 2009-03-08
Posts: 100+

Re: How do you stop sprites going through fake walls?

forever
if not touching color black
change y ny - 5
else
change y by 1


http://blocks.scratchr.org/API.php?action=projects&amp;type=newest&amp;return=image&amp;user=taddl
http://blocks.scratchr.org/API.php?user=taddl&amp;action=projects&amp;type=newest&amp;return=text&amp;num=1

Offline

 

#8 2012-09-10 14:11:22

bird12345
New Scratcher
Registered: 2012-08-17
Posts: 10

Re: How do you stop sprites going through fake walls?

Thanks I will give it a go.

Offline

 

Board footer