Kablooie! is a screensaver add-on for BeOS that simulates a fireworks display. You can adjust the number of fireworks, how quickly they go off, and how much detail is used in the explosions. This is my first complete application for BeOS, so it's fairly simple.
2001.12.16 - Tweaked some things around with the variables that control fragment detail, gravity pulling the fragments down, etc.; also made the pixels twice as tall, I found that this makes it look better (particularily in higher resolutions.) Coded a special case to handle 16-bit color depths, since most people seem to be using that; makes a nice speed increase, and also uses a tad less memory. If the color depth is anything other than 16-bit, it falls back onto a 32-bit drawing method and lets the OS scale the colors down. Finally, I added an easter egg of sorts, if it's Christmas eve or day, all of the fireworks will be red and green; on the 4th of July, they're all red white and blue :)
2001.12.11 - The first bugfixes already; after uploading Kablooie to BeBits, I found that tar won't preserve attributes (thus the icon I made dissapeared, and reverted to the standard Be application one), so I had to re-upload after compressing it with zip instead. Found some bugs with the sliders being pulled over too far to the right, and cleaned up the code in general, making a couple of small optimizations along the way. Now up to version 0.21...
2001.12.11 - Success! :)
Finally, all of the odd bugs and problems with the sliders in the config menu are worked out, and this screensaver is ready to be distributed as a beta version :) I sped things up in the fullscreen version by replacing a memset() call that cleared the whole off-screen buffer with code to just erase/re-draw the fireworks as needed. It's still a bit slower than I'd like, probably because of the copy of the back-buffer BBitmap to the current view to display it. I'll see if I can figure out a way to clean that up eventually, I have a bunch of little optimizations and code cleaning to do.
Along with figuring out what had to be done with the sliders in the configuration menu (as the BeBook screensaver section suggests, you need to create a custom BView, make the sliders there, and add functions to handle messages), the state of the screensaver is now saved between invocations - it remembers your settings from the last time you ran it. I also got to create an icon and set the MIME type for the screensaver (hooray for the BeOS Bible, I had no idea how to do that.) I'm not an artist, so the best I could come up with is a lit firecracker as an icon.
I set the version number at 0.20, since this is a beta release and I've had two major rounds of changes; once I make the changes I want to speed things up, I'll move it to version 1.00 (assuming no big bugs come up...) Now I get to try and upload it to BeBits... my first BeOS app complete, yay!
2001.12.09 - So close...
I'm so close to being finished with this! Unfortunately the weekend is coming to an end, hopefully I'll have some time one night this week to figure out the remaining issues and get this into a beta state, and eventually add an entry on BeBits for it :) I'm pleased with the progress that I've made this weekend, even if it's not completely done yet. Screenshots updated :)
I've made everything double-buffered by using a BBitmap (which is, despite it's poorly chosen name, actually more than one bit per pixel -- it's basically the same as a pixmap in XWindows, but a little easier to work with.) This also allowed me to start drawing points with direct memory writes instead of calling BView drawing functions, thus removing a LOT of function-calling overhead. Cleaned up a few other things in the source code, allowed for control over how many fragments each firework can have ("fragment detail") and made my configuration menu. The ONE problem that is holding me up from having this all finished and happy is with the BSliders that I'm using. For some reason, they work most of the time, but somehow the data for them gets corrupted if the middle slider is pushed all the way to the right :/ I don't think I set them up properly in their BView, I need to go back over the interface stuff in the BeBook. I struggled to figure out why this problem was happening into the wee hours of the morning, and got to the point where I was too sleepy to work on it - I was introducing more bugs and typos to my code than fixes! I'll get back to it later this week, and might post to the new Be developer list started this week (the ones hosted on Be.com are going to go poof on December 21st) for help if I'm still stuck. Most of the source code I could find dealt with customizing sliders, and not how to properly check the values they represent, etc. from another class. Bleh.
The BeBook is the best reference for writing Be code; I found some odd problems where links to things didn't work well (the link for item A would go to item X instead, for some odd reason...) but overall it's very well organized. I just wish it came with more sample code. Also found that the examples for some of the screensavers that come with the optional/samlpe-code/ directory won't compile on R5, which was annoying; apparently they were released with earlier versions of BeOS and the APIs changed a little since then.
The full screen screenshot is still of the screensaver preview & configuration menu, which seems silly but at the moment I don't have any way to get a screenshot of it while it's running. The "Grab" utility on BeBits is supposed to provide a way to capture active screensavers (you start it from a terminal with a "sleep 15;" call in front of it), but unfortunately the link to download that is broken. Guess I'll have to code one of my own...
I also need to make some HTML pages for the screenshots, that way the filenames don't change everytime I add one or change the image format they're stored in... But that can wait until I have real screenshots to show.
2001.12.06 - Today's lesson: don't try to reach beyond your Bounds()!
Well, it looks like this will be my first successful BeOS project, not Absolute Zero (which was my first attempt at writing a program for BeOS, but has yet to be 'successful'...) Having one project complete is better than none though :)
I've actually been working on this here and there for a few days. I put together the basic code classes and physics to do the fireworks on an SGI IRIX machine at work (an Octane, ool :) ) in OpenGL, abstracted out the drawing functions, and brought it home to plug the class into a screensaver framework on BeOS. I had looked over the example in the BeBook for making a screensaver add-on, as well as the source code to the BeBubbles screensaver... All did not go well, however! I spent the good part of the night chasing down a bug that would either crash the screensaver server, or bring down the app_server (which meant I needed to reboot...) Needless to say, I was constantly reminded of the line in the "virtual (void)" mp3 that comes with BeOS...
Once I had FINALLY found that as the cause of all of my crashes and put in some code to restrict the coordinates passed to StrokeLine(), the rest of the program clicked right into place without a single glitch. Given, I had not only worked out the bugs previously on the IRIX test version I had made, but I was finding & fixing little bugs and performace problems as I was hunting for the dreaded app_server crashing bug. It works now, which is all that matters!
It's not done yet, however. I'm going to try to do some double-buffering, and maybe switch to a DirectDraw() drawing scheme to see if I can increase the overall speed. When there's a decent number of fireworks going, the whole thing kind of bogs down... and the particles are too small right now to really look good. I also want to add some sliders to the configuration panel so that the number of fireworks launched at once, time before explosion, etc. can be tweaked. Tomorrow is my birthday, maybe finishing this by the weekend will be my present to myself...
I've also been won over by the BeIDE. At first I was doing everything from the command line with Makefiles and such, but for a project such as making a screensaver add-on, the IDE is a wonderful help. Remember all of the switches you need to make a shared object? And to link against the other .so's you need? Bah. The more I use the IDE the better I like it, I guess I just had to get over the bad taste that the MicroSoft Visual C++ IDE left in my mouth... big, slow, klunky and difficult to use without spending a lot of time learning the interface. The BeIDE is much easier, but admittedly still took some time to figure out.
It's 5:01am, the sun will be up soon... I should go to bed.
END OF LINE.