Monday, July 11, 2011

More Rainstorm Progress

I've spent some time over the past couple weeks working on The Rainstorm again, and it's getting pretty close to an update. There's one minor bug to fix, and I want to add a pause menu. After that I'll release a new version.

Tonight I created some graphics for the menu buttons, instead of the rather unattractive QNX buttons.

I also changed the font, which turned out to take lots longer than I thought.

Recently I also added a help screen and tweaked the gameplay speed to make it a little less boring.  I still want to radically alter the gameplay, but I might have to wait until the NDK comes out so I can code it up in C++ and OpenGL to get the raw horsepower for the visual effects. 

Saturday, June 18, 2011

HD Progress

The Rainstorm has now been converted to HD foreground graphics, with low-res water effects and background.  With the water effect as such low resolution (1/4 size) as it is to get good framerates, it looks pretty awful compared to what it was (1/2 size).

I decided that it's better to have a crummy visual effect with better gameplay than the opposite.  The only way I think I can get good performance out of this game (mostly the water effect) is to convert to C++/OpenGL once the PlayBook native SDK is released.  And I do want to do that.  One of my coworkers today had a great idea to make the game more fun, but it will be a lot of work.  I might just have to save the idea until I port it to C++/OpenGL.  Of course, there are other games I want to do in 3D...

I previously mentioned how I got high-quality foreground graphics with low-quality background, and yesterday I thought of  a much simpler and probably faster way to do it, so refactoring was much less of a headache.  In short, the app now runs at full resolution, including all of the foreground bitmaps and such (no scaling down),  and the background is rendered at low resolution and upscaled.  That way only one thing needs to be scaled, rather than a whole bunch of things.

Thursday, June 09, 2011

Rainstorm performance analysis

I added a display for frames/second (fps), and discovered that my multi-touch version runs at about 13fps, so lower than I guessed by eye.  That means the HD version must be at about 5fps.  I decided to do some subjective profiling by turning on and off various features (such as drawing only the ripples, turning off sound, etc.) to find out what the performance hog is.  Of course it's the ripple effect.  Nothing else makes  a huge difference, basically everything else drops the rate by about 3fps total.

So I tried changing the resolution to 256x150 (1/4 screen res), and poof, we got 30fps.  The ripple effect is a little grainy, but I think with everything else at full res it might not look too bad.  I'd rather have a smooth, fun game than a choppy, nice-looking game any day.  If RIM ever decides to improve the performance of the flash runtime I can bump the resolution back up.  I also tried 384x225, but that was about 20fps.  And I tried changing the resolution of just the ripple map (behind-the-scenes calculations) and that helped, but the 256x150 combo was the only setting that got 30fps.

So now I'll be updating all the graphics to work well at this new resolution.

Wednesday, June 08, 2011

How to control the boat

As I watch people play my game (friends and family), I've noticed that everybody tries to control the paper boat as if it were a real boat in the water.  They start with their finger on the boat, then drag it where they want it to go.  With real water, I see two ways of making the boat move without touching the boat, and without blowing.

One, you can put your hand behind the boat and make a wave that moves the boat.  Two, you can put your hand in front of the boat, then push water away from the boat to make a sort of slipstream.  People seem to use a combination of both, especially with the new control scheme which acts like blowing the boat.  So for really intuitive control, I need to make a sort of slipstream control.

Here's what I have in mind: when the user is just touching (not dragging), make a repulsion force at the touch point.  When the user is dragging, make a time-decaying slipstream.  Time-decaying means it's strong when they first make it, but over time it weakens and goes away completely.  I envision the slipstream only lasting maybe 3 seconds total, but only really giving a good push for 1 second.  If you drag along right in front of the boat and kind of lead it along, it will follow your finger, and if you make a quick curvy swipe it will follow the path for about 2 seconds and then continue with its own inertia.

One thing I like about this idea is it's a small-scale "fire and forget" type interaction, where you tell the boat (or leaves) where to move in the near future, and then you can do something else while they're moving.  Of course, you only get a few seconds in between each move, but that's good for a game.

I'll code this up soon and let you know how it goes.

Tuesday, June 07, 2011

The Rainstorm now supports multi-touch

After just 40 minutes of work, The Rainstorm now supports multi-touch, and it's pretty sweet.  The Air documentation is very good, with the examples especially.  The one downside is that I don't get mouse events now, so I need to figure out how to bring those back (while also keeping multi-touch) so I can continue to develop without having to test on the physical device every time.

For the developers here, this is the Air documentation page that is most useful:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/TouchEvent.html

Saturday, June 04, 2011

How to get high-res images in a low-res Air app

I thought about another way I might get partial HD graphics working.  The problem is that the resolution of the screen is 1024x600, and setting the application to that size (even without changing the assets) slows things down too far.  So I set it to 512x300 and then let Air scale it to full res to get reasonable performance.  This means everything is pixelated doubly.

After noticing that text and standard buttons render at full HD, I had the thought of loading a bitmap that's double the resolution that it needs to be, then scaling it down before letting Air render it.  This works for the one item I tested it on.  Some of my other objects use a different method for rendering, so those will take some work to HD-ify.  Here's what the code looks like:


// This image is double the size it needs to be
[Embed(source='rainStormTitleFinalHD.png')] public static var RainStormTitleImage:Class;
titleImage = new Image();
titleImage.setImage(new RainStormTitleImage);
titleImage.x = -30;
titleImage.y = 10;

// This part is where we scale it down.
titleImage.scaleX = 0.5;
titleImage.scaleY = 0.5;

addChild(titleImage);
The result of this is that when an Air app designed for 512x300 is upscaled to 1024x600, the above image is the perfect resolution (not pixelated).

Here is a comparison of a section of the screen.






First the original, pixelated image.










And here's the HD image.

So it's clearly working, and so far it doesn't affect the framerate noticeably.  But it's only the title screen that's setup this way.

Unfortunately, most of my game objects use BitmapData and copyPixels to an off-screen buffer which is eventually rendered in the normal Air way.  Before GPU acceleration in Air, this was a speedy way of drawing graphics that don't need to be scaled or rotated.  With GPU acceleration, this way is slower.  So I need to make everything a Sprite or some such and just do things with the "normal" Air method to get HD bitmaps in a low-res app.  And that's a fair bit of work.  But right now it's not my highest priority.

Friday, June 03, 2011

HD attempt and better controls

Summary:

  • HD is too slow for now
  • Repulsion control is lots more fun

A few days ago I converted the main resolution of the app to full HD on the playbook (1024x600), because the appworld version (1.0.1) is upscaling half that resolution (512x300).  I did this because I wasn't sure how smooth it would run on the actual device, and I'm glad I did, because at half resolution it runs at about 20fps.

Last night I tried running at full HD resolution, with the exception of the processor-hungry water ripple effect still at half rez.  Even with that, the framerate dropped to about 8fps.  Unplayable.  Rats.
So I'll have to wait until BlackBerry improves the performance of flash before I can really give HD.  I think the game still looks great without HD, and I'd definitely much rather play it with a higher framerate.

The other thing I tried last night was an improved control mechanic.  Version 1.0.1 uses only the water ripples to move the boat around.  I wanted it to be this way, but it ends up being too hard to control and just frustrating.  It was a good experiment, but it's just a poor way to control.

So version 1.0.2 adds a repulsion mechanic, so wherever you touch the tablet, the boat goes away from that point, sort of like if you were to blow air at that spot.  You still make waves, and the waves still affect the boat, but now the control is a lot more responsive and predictable.

Coming up next: multi-touch support, help page, movable leaves, multiple boats,
Coming up after-next: levels, intelligent enemies, online high scores, achievements, (maybe) upgrades.

Wednesday, June 01, 2011

A month of Playbook

It has been nearly a month since I received my BlackBerry PlayBook.  The Rainstorm plays alright on it, although the game isn't as tight and fun as I'd like it to be.  It's more frustrating to try to get the boat to move the way you want than anything.  So after playing with my new gadget for nearly a month, I'm finally getting back into updating the game and improving the gameplay.

Just tonight after an hour of work I was able to figure out how to transition half of the graphics to HD-quality, but the main water ripple effect is still half of the playbook's screen resolution.  It's scaled up to full-screen, but it's calculated at half that size.  It's an issue of performance.  The game runs at somewhere around 15-20fps on the playbook at half resolution.  I still need to check whether using the GPU helps, but I'm doubtful, since the ripple effect heavily relies on filters, which are not supported on the GPU with flash.  So what this means for now is that I'm likely stuck with nice HD-quality above-water graphics (boat, leaves, text), but anything below-water (coins, shadows) is half-size.

Near-term plans for improving the game are:
  • HD graphics (except ripples)
  • Smoother controls
  • Move leaves with ripples
  • High score list
  • On-line high scores
  • Help section
More distant plans:
  • Multiple boats
  • Moving enemies that you destroy by moving the leaves in their path
  • Storyline, multiple levels, end game conditions
  • Port to android, iOS
I plan to keep the game at the same price for all of the near-term improvements, but once I get the "distant plans" implemented, I'll raise the price by some amount.


In case anyone is curious, my high score on the playbook is $2.35.  Good luck beating that!
It has been nearly a month since I received my BlackBerry PlayBook.  The Rainstorm plays alright on it, although the game isn't as tight and fun as I'd like it to be.  It's more frustrating to try to get the boat to move the way you want than anything.  So after playing with my new gadget for nearly a month, I'm finally getting back into updating the game and improving the gameplay.

Just tonight after an hour of work I was able to figure out how to transition half of the graphics to HD-quality, but the main water ripple effect is still half of the playbook's screen resolution.  It's scaled up to full-screen, but it's calculated at half that size.  It's an issue of performance.  The game runs at somewhere around 15-20fps on the playbook at half resolution.  I still need to check whether using the GPU helps, but I'm doubtful, since the ripple effect heavily relies on filters, which are not supported on the GPU with flash.  So what this means for now is that I'm likely stuck with nice HD-quality above-water graphics (boat, leaves, text), but anything below-water (coins, shadows) is half-size.

Near-term plans for improving the game are:
  • HD graphics (except ripples)
  • Smoother controls
  • Move leaves with ripples
  • High score list
  • On-line high scores
  • Help section
More distant plans:
  • Multiple boats
  • Moving enemies that you destroy by moving the leaves in their path
  • Storyline, multiple levels, end game conditions
  • Port to android, iOS
I plan to keep the game at the same price for all of the near-term improvements, but once I get the "distant plans" implemented, I'll raise the price by some amount.


In case anyone is curious, my high score on the playbook is $2.35.  Good luck beating that!