Pages: 1
I'm trying to make a game involving lasers and mirrors, and I need to figure out how to make lasers bounce if they're touching a mirror. I'm using a color sensor to detect mirrors. Does anyone know a good way to make the laser bounce off of the mirrors? Or at least to figure out what direction the mirror is pointing without switching off of my color sensor.
Offline
Are you using a pen or stamping to make the laser? That would help me with telling you how to make the laser turn.
Last edited by ErnieParke (2012-08-06 17:45:37)
Offline
When they touch the mirror, this script should cause the light to bounce the correct way:
(This script was taken from the wiki)
when gf clicked go to x: (0) y: (0) point in direction (pick random (-179) to (180)) set [Move Speed v] to [0] forever move (Move Speed) steps if <touching [mirror v]?> change x by (([sin v] of (direction)) * ((0) - (Move Speed))) if <touching [mirror v]?> point in direction ((180) - (direction)) else point in direction ((0) - (direction)) end change x by (([sin v] of (direction)) * (Move Speed)) end
Last edited by Prestige (2012-08-06 18:02:43)
Offline
Prestige wrote:
When they touch the mirror, this script should cause the light to bounce the correct way:
(This script was taken from the wiki)when gf clicked go to x: (0) y: (0) point in direction (pick random (-179) to (180)) set [Move Speed v] to [0] forever move (Move Speed) steps if <touching [mirror v]?> change x by (([sin v] of (direction)) * ((0) - (Move Speed))) if <touching [mirror v]?> point in direction ((180) - (direction)) else point in direction ((0) - (direction)) end change x by (([sin v] of (direction)) * (Move Speed)) end
Thanks! This works well! I'll be sure to give credit to you and the wiki. It would be nice if it worked with diagonal mirrors as well as horizontal and vertical, but I guess you can't have everything.
Offline
ErnieParke wrote:
Are you using a pen or stamping to make the laser? That would help me with telling you how to make the laser turn.
I'm using the pen. Someone else already came up with a script for it though.
Offline
Thrystor wrote:
ErnieParke wrote:
Are you using a pen or stamping to make the laser? That would help me with telling you how to make the laser turn.
I'm using the pen. Someone else already came up with a script for it though.
Okay.
Offline
Thrystor wrote:
Thanks! This works well! I'll be sure to give credit to you and the wiki. It would be nice if it worked with diagonal mirrors as well as horizontal and vertical, but I guess you can't have everything.
Does this not work on diagonals? Have a look at this, it might help you
Last edited by Prestige (2012-08-07 08:26:01)
Offline
Pages: 1