Angel Harp (is the Weirdest Instrument)

It was a joke, back in September. A goofy idea, amidst a brainstorming session of merely silly ideas. It’s a heavenly harp! And when you turn it upside-down, it becomes a Devil Harp! Ha, ha.

The YouTube trailer would probably look something like this:

I hacked Angel Harp together in my spare time. Four long months! The plan was to finish by Halloween of 2011, but it took considerably longer than expected. The synthesis was completed in one week, the sound effects in another week. Standing on the shoulders of Twang, Angel Harp produces somewhat-realistic tones (like an actual harp! Complex filtering!) And it has 3+ dozen strings, for serious plucking power!

And, the graphics… Let’s talk about that.

Once the Halloween deadline became improbable, I decided to hack each feature until it was “good enough.” If any feature became an eyesore, then I’d revisit it — either for version 1.0, or a future release. The clouds were redone a couple times. I had grand plans for the harp itself, using an (awful, buggy) harp modeling tool; in a future version, you can draw your own harps, and skin them with fancy materials, I think.

Angel Harp! Heaven!

Continue reading

Flash 3D: A change of heart?

Yesterday, I posted a damning critique of Flash’s native 3D.

Today I noticed that if you right-click on yesterday’s SWF and show the redraw regions, you can see that it’s redrawing the contents of the entire stage, even though I put the scene in a scrollRect. Is it seriously rendering a scene that’s thousands of pixels wide before displaying it ?!?!?!? Oh, no. No they DIDN’T.

Today I ported the scene to the Away3D rendering engine. Here’s the result:

It’s beautiful, and provides access to low-level drawing routines, light sources, normal maps, … It was speedy at first, then slowed down considerably when I added the glowing floors. (Each glow is 16+ triangles right now, for various reasons including: I can’t render objects in my own custom order.) This makes yesterday’s version look performant, I’m reluctant to admit.

Possible next steps:

  • Reduce the native 3D rendering area, see if performance improves?
  • Grow beyond Flash, embrace the future and try Unity 3D?
  • Dump this project, finish that iPhone game I started, make a million dollars in 2 weeks?

Flash 3D makes me sad

I’ve been dabbling with Flash 10’s native 3D support. Try my engine:

Click to set the focus. Use the arrow keys to move. Touch blocks to illuminate.

I’m disappointed with two things:

1). How much time is required to create a 3D engine, even a grid-based one like mine. I’ve been wrestling this project for 4+ hours every day, for a week. I feel like I must be lagging behind, but there are ten thousand things that will go wrong when developing in 3D. The paradigm is uniquely punishing, there are always edge cases where some polygons aren’t drawn correctly. This project hasn’t been a joy.

Also:

2). Flash’s native 3D is not suited for a high-performance application like this one. It would be fine if I was only spinning a few DisplayObjects in space. However, the scene above displays up to 125 Bitmaps simultaneously. (Light all 25 bulbs (3 Bitmaps each), stand in the corner facing them, and the 25-segment walls.) 125 Bitmaps would be child’s play in OpenGL. But after you light a few blocks, Flash Player chokes pretty hard.

Here’s another version that uses a BlendMode on the lightbulbs. It looks great, but its performance is even less acceptable.

Here’s an early version that uses my own 3D computations, and the Graphics API. Also it has a limited field of view, which I widened for the latest builds. The performance is surprisingly high. I abandoned my custom 3D when I reached this point; drawing lines around each cube face was expensive, so I switched to Bitmaps, and the native 3D.

The cube faces are set to width & height of 100. However, the bitmaps are higher resolution, a 200×200 region is shown. They’re being downsampled at 100×100 before they’re rendered, not by my choice.

At runtime, I get periodic warnings like these:

Warning: 3D DisplayObject will not render. Its dimensions (8238, 1628) are too large to be drawn.

What?! How is this happening? I swear that any blocks behind the camera are being removed from the Stage. (Actually, this is difficult to verify. If I shrink the scene, Flash magically applies the 3D perspective with a weird projection, and distorts everything in Lovecraftian dimensions.) Please, Adobe, tell me that you’re not rendering the scene at 8000 pixels wide, then scaling it down to my 700×400 window, frame after frame?

Also note that you, the developer, are responsible for drawing the DisplayObjects in the correct depth order (farthest to nearest), Flash doesn’t handle it automatically. This is known as “2.5D“, and it’s wildly inconvenient.

So, I’m pretty disappointed with Flash 10’s native 3D. Even with my limited 3D experience, I dislike how it renders the scene (I’m not alone in this) and the performance is obviously sub-par. This technology will not bring 3D games to the web, it cannot.

I need to decide whether to endure its shortcomings for 4 more weeks, or if I should abandon this project altogether. There are moments when you realize you’ve outgrown something you used to love, and this may be one of mine.

Toaster Bro alpha: 10 days later

Did I mention my new game, “Toaster Bro”? Play Toaster Bro alpha version 1!

(You will need Flash Player 10.)

Ten days have elapsed since I shared this version with friends (who are unwittingly being used as play testers). It’s time for a “wrap-up” meeting, because I want to examine what went wrong/right, and instead of a meeting it’s a blog post:

Continue reading

8-bit NTSC artifacts using Pixel Bender

By request, here’s a quick ‘n dirty test harness, and sample code, for NTSC artifacts in the style of the 8-bit Nintendo Entertainment System (NES):

Click the animation to change scale & scroll speed.

Source code & .fla: nes_ntsc.zip

The .pbk code is not optimized yet. The code is fairly explicit, I tried to explain how it works in the comments. Blargg’s pages have better explanations tho.

The test harness lets you select two flavors of the effect. The numbers 8 and 12 denote the width of the lowpass window used for applying crosstalk. 12 is more processor-intensive, but will look “smoother”, which may not be what you want. The mathematics can be reduced to a few (long) lines, which should reduce processor overhead; I want to do this in the future. unic0rn left some nice comments suggesting more routes to optimization.

The filter still needs some tuning. Areas of solid (non-black) color have diagonal stripes in them. I believe that normalizing the strengths of the filters will fix this.

To be continued…

NES Pixel Art

My tile engine is getting a facelift, I’m scrapping the Atari 2600 palette, and switching to the glorious 56 colors of the Nintendo Entertainment System.

Eventually I want to add NTSC artifacts using Pixel Bender. For now, I have to produce a small miracle of art assets, and use the tiny palette effectively. I never thought I’d study old Nintendo games, but that’s exactly how I spent my evening.

According to Tsugomo, the eye perceives brighter colors as being closer. Most games with decent art have solid blocks brighter than the background.

Mega Man 3 - Needle Man

Continue reading

Tile engine is go!

Homemade tile engine!

screenshot

Click to play.

  • Move: Arrow keys, or WASD
  • Shoot: Mouse button, or IJKL

Make sure you grab a weapon in room #2, so you can shoot the orcs. Currently, there are 9 rooms for romping.

Not one pixel of the art should be considered “final”. Most sprites & tiles have a ColorMatrixFilter that “skins” them with four particular colors (see my post detailing this technique). In some respects, this is wonderful, as the colors can be randomized, and it’s easy to change the palette of an entire room. Unfortunately, to maintain retro look & feel, I chose the Atari 2600 palette. The dark colors are over-saturated, the pastels are unexciting, and the hue distribution is completely wrong (nearly half the colors could be considered “green”). This will be dealt with.

An earlier screenshot shows some vector art. Unfortunately, the vectors currently require Flash 10. I’ve disabled this feature… for now.

How to Crash Flash

Miles and I submitted our new Flash game to the 4th Jay Is Games competition. In Space Kitteh (pronounced something like “Space Kitty”), the object is to rescue cats in an outer space environment. The physics are a real treat — it’s impossible to “fall” off the landscape. If you get lost, just wait for the solar system’s gravitational pull to drag you home.

It’s a lot of fun, but I need to warn you about a serious problem in Space Kitteh. This is a heads-up for users of Windows Flash Player —

Our game will crash your browser.

Continue reading

The phantom design pattern

I’m working on my first serious video game project. This may be be the most difficult application I’ve architected to date. (Why aren’t there any books on game design patterns? Oh well… The chance to forge unknown territory is why I love programming!)

Cube and I are still trudging through the first cycle of refactoring, but I think the structure is almost where it needs to be. One more day? Two? Then we’ll start programming the “fun” stuff again ;)

Kudos to everyone who made gmane.games.devel.sweng live and breathe, your news archives have proved invaluable.