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

#1 2011-06-27 14:50:28

mariobrosrule
Scratcher
Registered: 2008-06-09
Posts: 1000+

Laser Wall Detection?

Like in Toxic (Nitrome) They have lasers that when they hit the wall, they stop.

I want to make something like that in Scratch. But It has to be fast too.

Like a straight line that changes length depending on the wall.

I've seen this in Scratch one time. But I forgot what its called.

Offline

 

#2 2011-06-27 17:40:01

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Laser Wall Detection?

The best way to do this is the "forced" method.  Basically, instead of letting Scratch repeat a cycle until it hits a wall, you force it to run the entire cycle in one go.

Say you have a sprite that is 20 pixels long and 1 or 2 wide.

Your script would look something like this:

when I receive (laser)                                         If you're using a broadcast
go to (player)
set (touching?) to (False)
point in direction (direction of player)
if touching?=False:
   move (20)
   set (touching?) to <touching wall>

copy the above at least 16 times.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

Board footer