Monday, September 13, 2010

Halloween Live Wallpaper v1.0

(Android Market Link)
(YouTube link)

Had a few requests for one of these, and it was fun to put together! You get a collection of Jack-O-Lanterns sitting atop gravestones, with a full moon and swarms of bats in the background.  There's a cartoony haunted house with glowy eyes and everything.  :)

The prefs on this one are a little thin on the ground currently, but I expect to add more stuff over the coming weeks.  Basically, you can control the density of the bats and the color of the candles in the pumpkins, the camera speed, and can set it to only spawn bats when you touch the screen.

On  the technical side, the particle system now supports animated meshes as particles, which is what the stream of bats is composed of.  Particle systems now can have their spawning enabled and disabled at will, plus a few other minor features that should come in handy in the future.  The visibility system worked out for Bamboo works well in this case as well.  It's not nearly as object intense, but it's getting a few fps back.

I'm quite happy with how it looks overall, it was a fun project and it's cool to get it out there for folks to see!

Saturday, September 11, 2010

An Android Logging Class That Writes to SD Card

In case anyone's interested... I'm currently trying to work out the cause of a very uncommon lockup that happens with one or two of the wallpapers.  It only seems to happen on HTC phones so I'm honestly guessing it's a driver bug, but the real problem is that it happens with no apparent cause with a frequency of perhaps once or twice per day.

I've got an HTC Incredible here that I have seen it happen on, the problem is actually seeing what's going on.  I'd normally use the system log, but since this problem can lock-up the phone, that log gets wiped out upon a restart.  So, I've tossed together a simple static logging class that can output to an SD card.  The filename is tagged with the date and time upon creation, so it won't overwrite an earlier file, and since it's on the SD card it can run and get plenty gigantic.  I've put calls to LogToSD.write at the top of basically every single method on the wallpaper, so it's going to get big by the time I see it lock up next.  :P

Here's the class, if anyone's looking for something like this.  Don't forget you'll need to set uses-permission WRITE_EXTERNAL_STORAGE.

public class LogToSD
{
    static PrintWriter outFile = null;
  
    private static void initialize()
    {
        try {
            File root = Environment.getExternalStorageDirectory();
            if( root.canWrite() )
            {
                Calendar rightNow = Calendar.getInstance();
                long day = rightNow.get( Calendar.DAY_OF_YEAR );
                long hour = rightNow.get( Calendar.HOUR_OF_DAY );
                long minutes = rightNow.get( Calendar.MINUTE );
                long seconds = rightNow.get( Calendar.SECOND );
              
                String date = day + "-" + hour + "-" + minutes + "-" + seconds;
              
                File gpxfile = new File( root, "log_" + date + ".log" );
                FileWriter gpxwriter = new FileWriter( gpxfile );
                outFile = new PrintWriter( gpxwriter );
                outFile.write( "\n\n----- Initiating LogToSD Session -----\n" );
                outFile.write( "----- Start Time: " + date + " -----\n\n" );
            }
        } catch (IOException e) {
            Log.e( "LogToSD", "Could not write to file: " + e.getMessage());
        }
    }
  
    public static void write( String text1, String text2 )
    {
        if( outFile == null )
            initialize();
      
        Calendar rightNow = Calendar.getInstance();
        long minutes = rightNow.get( Calendar.MINUTE );
        long seconds = rightNow.get( Calendar.SECOND );
        long ms = rightNow.get( Calendar.MILLISECOND );
      
        String time = minutes + ":" + seconds + "." + ms;

        outFile.write( time + "\t" + text1 + " " + text2 + "\n" );
        outFile.flush();
      
        Log.v( "LogToSD", text1 + " " + text2 );
    }
  
    public static void shutdown()
    {
        if( outFile != null )
            outFile.close();
    }
}

Wednesday, September 8, 2010

Thunderstorm v1.15

  - New Feature: Tap to summon lightning!

This one's pretty simple but a few folks have asked for it.  Basically, there's now a setting that will cause lightning to flash whenever you tap on the screen!  It's a bit silly, so it's off by default, but it's there if you want it.  :)

This will be uploaded in the morning.

Aquarium v1.91 & v1.92

  - New Feature: Fish Selection Window
  - Update: Twelve Fish at a time!

This update happened pretty soon after the last one - sorry about that.  Generally I'd have waited longer, but v1.90 had an unfortunate bug that resulted in the particle bubbles being visually wrong on some phones.  I hadn't excluded them from mipmapping, and on some handsets the automatic mipmap generation doesn't work correctly with an alpha channel.

So, v1.91 was primarily to fix that problem.  At the same time I'd started working on a popup window for selecting your fish species, as the tap-to-cycle approach was getting kind of ridiculous when there's a dozen fish in the list.  The new window has all the available fish listed.  You tap the thumbnail, the window appears, and you make your selection.  It's a lot more elegant at this point, I think.

While I was messing with the UI, I figured I may as well use up that couple FPS we gained and allow 12 fish instead of 10.

This all went in just fine, until I started getting mail asking how to remove a fish.  Now, the thing to remember is, when I'm testing this stuff I ended up wiping my preferences a lot and starting from the default values... so while I'd confirmed all 12 slots worked I'd really just been testing the new functionality, and somehow managed to completely forget that you might want to take away fish too.

So, v1.92 was a rush to fix this problem, by adding the "no fish" red X to the popup window.  I confirmed it worked and got that out as quickly as possible, so hopefully not too many people needed to update twice in a day.  Sorry folks!

Thursday, September 2, 2010

Bamboo Forest v1.0

(Android Market link)
(YouTube link)

In the mood for something a bit zen?  Bamboo Forest is a serene scene of waving bamboo trees with shafts of light from above.  It's got a mess of color preferences for fog and light, along with settings for fog density and camera speed, and controls for enabling/disabling the particles and light rays if you don't like them.

There's a surprising amount of complexity to this scene, and a lot of time went into making it perform well with that many object visible and at that detail level.  It works well and is quite pretty!

A lot of useful functionality came out of this one, development-wise.  The export tools can finally handle multiple animated objects being exported in one file, for one thing.  Originally, the scene had somewhere in the neighborhood of 100 separate animated models at a time, and that was just too much for the phone to handle.  Some of these got thinned, while others got combined to reduce the total object count.

There's also a basic visibility system in place that avoids updating and rendering objects that are off-camera.  That doesn't sound like much, but none of the other wallpapers so far have really justified writing something like that, as generally they're floating around 5-15 objects at a time.  These features combined with a lot of profiling and optimizations should help make future projects go quicker and smoother, as a bonus.

Aquarium v1.9

 - New Feature: Particle-system based bubbles
 - Update: A bunch of optimizations

Most of this update is invisible, honestly.  Been doing a lot of optimization for high-object-count scenes and the library changes have been moved into Aquarium as well.  This gets it a couple of frames per second, but honestly it's high enough already that you probably won't notice.

The noticeable change is the addition of particle-based bubbles!  These are exercising a new system that is starting to work its way into the various wallpapers are updates are done, and feel a lot more dynamic than the old ones.

The original plan was to get better fish selection and a seahorse into this update... unfortunately other stuff got in the way, so that'll be in next round.