I've only got one screeny today, but hopefully tomorrow I'll have a video for you guys to watch!
A few posts back I showed you guys the Kremlin Laser that peels open and fires a laser beam. Well, I never showed the laser beam in those screens, because... well... they didn't exist at the time. Anyways, I recently coded them up, and, via the magic of mathematics, they can now cause damage to whatever they come in contact with, which is pretty neat. Here's a screeny of the Laser in action:
Here's a question for you guys, what color should the laser be? Mark thinks green, and I'm not too opinionated about it, but what do you guys think?
This is what I've been working on for the past couple of days now, and its finally starting to come along. Before I got this working, whenever a sound was requested to be played by an object, it was just played regularly, regardless of the camera's location relative to the sound location. This got kinda annoying sounding when a SAM site across the map would fire a missile and the sound would be heard loud and clear 20 miles away. Anyways, after much thinking, I finally decided on a solution to this problem.
Step 1: Store the information related to the sound somewhere
I realized that if I wanted 2D sound, I needed to know the location of the sound, its 'attenuation' rate, etc. I created a simple structure called Sound2D (wierd huh[grin]), which holds the location of the sound, its fade rate, and the channel it is playing on (I'm using FMod BTW). Then, whenever a call was made to Play2DSound(), these variables could be stored and recalled later. You may be thinking, "Why not just figure out the fade value when you first play the sound instead of saving it for later?". That works fine when the sound is a short clip, such as a bullet richochet-ing or an explosion, but for longer sounds(such as air-raid sirens) we wanted to have them be able to fade in and out as the player flew past.
Step 2: Fade the sound based on distance
The next step was to then update through all of the Sound2D's and adjust the volume of each one for changes in the camera position. In order to do this, I just looped through the list of Sound2D's, calculated their distance from the camera, and then applied this handy little formula I came up with to get the new volume setting (0-255).
float volume = (attenuationrange/distance)*255;
Then it is just a matter of setting that sounds channel to the calculated volume, and voila, 2DSound that fades in and out depending on the distance to the camera. I wish I could make a movie showcasing this effect, but I'm afraid I haven't the time nor the patience tonight to wrestle with Windows Movie Maker.
Been doing lots of them.....
So today Mark and I went to the X-Prize event in Las Cruces, NM, because my dad managed to get us some VIP tickets. As some of you may know, John Carmack is a strong proponent of private space flight, and created Armadillo Aerospace to build a private spacecraft. Anyways, he was at the event, and we found out that one of my dad's friends could introduce us to him. At this point, Mark and I are pretty happy, because its fucking John Carmack. Then, my sister calls from my house (which is an hour away), and says she needs us to take her somewhere, so we have to leave before we meet Carmack because my sister couldn't be 30 minutes late for a goddamn birthday party.... So lets see, last week North Korea ruined my Saturday, and this week it was my sister, who's next?
More tomorrow hopefully, Peace Out!