Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] - 2D Reflection Demo

Author
Message
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Jan 2013 20:18 Edited at: 24th Jan 2013 12:34
Heavily commented so hopefully everyone can understand how it works.

Hold the left mouse button to draw a "mirror", or reflective surface, then release button to place it. The laser will reflect off the surface and continue on until it's strength (or depth/length) has died off.

One thing the demo does not take into consideration is a mirror's position in relation to another. Meaning that if you position mirror 1 then decide to place a 2nd mirror closer to the emitter thus cutting off mirror 1 from being hit, the 2nd mirror actually gets ignored. The laser scans for mirrors in the order that you place them, not as they appear physically on screen.

To correct this, you would need to check collision with all mirrors every time you reflect from one.



Version 1


"You're not going crazy. You're going sane in a crazy world!" ~Tick
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Jan 2013 09:49 Edited at: 24th Jan 2013 12:34
After several hours of headaches for what should've been a simple 5min job, I believe it's done. The laser will now reflect properly based on position of the mirrors and not the order they were placed in. It will now also allow the laser to reflect from the same mirror more than once (which wasn't possible before, oops).

Press spacekey to animate the laser.

Version 2


"You're not going crazy. You're going sane in a crazy world!" ~Tick

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-03-28 11:48:12
Your offset time is: 2024-03-28 11:48:12