Friday, November 20, 2015

Data Driven

I must say that data driven programming can be very effective in games. What does data driven programming mean to me? Writing a generic system that takes in variables to be used during processing.

For example, a generic system for game projectiles where variables include: speed, image file, sound effect, shoot delay, etc.

Another system for particle effects.

Another system for zombies.

Another system for weapons.



My first exposure to this approach was way back in 1999, when I explored the Kingpin: Life of Crime game source out of curiosity. I considered sprinkled code like this to be relatively welcoming:

G_Items.c from Kingpin: Life of Crime
At the time I found most of the other code to be rather esoteric. Even without programming expertise, one can safely assume the code above represents data for a fuse key. It is noticed while playing that  "world/pickups/coil.wav" is the sound effect that plays when picked up, and uses "models/pu_icon/coil/tris.md2" as an inanimate 3D model file. At the time, I modified some of these values and ran the game to my amusement, eager to learn more.

Data driven in Zombie Guard

Fast forward to 2015. Such a seemingly minor experience had a drastic impact on me. Most of my game projects are data driven - partly out of habit and partly out of simplicity. For example, here is the data for the blunderbuss that can be upgraded five times in Zombie Guard:

Additionally, here is one of the five sets of data for the blunderbuss at rank 1, referenced in the wtypes table inside g.wg_blunderbuss:

Data like this is passed into the function for shooting the weapon, and the generic system for projectiles uses this data as well. It is easy to compare and contrast various weapons.

One of the greatest benefits of this approach is that it scales well as content is added to a game project. For example, I could easily create a new weapon by duplicating just the data for this blunderbuss and modifying some of the variables.

Any fancy special case behavior can be controlled through a new value.

Sometimes hard coding is better

Sometimes a data driven approach is not always better. I was fortunate to have forgone the approach in Defend Your Nuts for the weapons, instead, opting for a hard coded approach.

Defend Your Nuts features a bow with variable number of arrow projectiles, an instant single-target rifle, a bazooka with baby rockets, and a shotgun with variable instant damaging pellets. How could I generalize this? It would have been over engineering, since I knew firmly I was never going to append additional weapon content.

There are two examples of shootEquippedWeapon above. The first is the data driven approach, which for such few number of weapons, would have been more complicated than the second approach that ultimately I pursued.

In other words, data driven approaches can be suitable for large volumes of features that share similar functionality, specified through a set of data. It depends on the situation. Otherwise, other approaches can offer more flexibility.

Room for growth

I'll probably continue to make use of data driven programming. In the future I want to utilize Excel spreadsheets as a means of authoring my data. That way, data variable names are only written once for each column, useful graphs can be generated off to the side, computations can be utilized to help me balance the game.

In the first example above from Kingpin, written in C, you would have to consider the layout of the structure and maintain the correct order of value types. It was just the nature of the language. In my examples using Lua, equating the variable names gets rather tedious too.

I see spreadsheets as being very useful in my future projects...

Sunday, November 15, 2015

Battle Modifiers

Lots of things to blog about! For this post, I want to focus on a small feature that took a few iterations.

I like to sprinkle in a bit of randomization into my games. Little surprises here and there to keep things interesting. In my previous game Zombie Tactics, characters could go off and scavenge for supplies during a battle. It offered risk versus reward - scavenging with many characters would provide the best rewards, but the player would risk getting wiped out with the remaining characters during a battle. On the other hand, not scavenging would be safer in the short run, but would forgo improved equipment and bonuses in the long run.

The simplest approach I took for Zombie Guard was a spinner wheel, reminiscent of prize wheels at a carnival. It was designed to offer temporary benefits and disadvantages. It was decorated with placeholder art. First of all, I was discouraged to spend a great deal of time making it look presentable. It was confusing too. Even worse, tapping the wheel did not feel very interactive. I like to at least give the illusion of choice.

The second iteration was just naive grid of selections. At least here, it felt like there was a choice, even though the function was just simply returning a random battle modifier. Overall this approach felt very rushed. With this implementation of the feature, it worked, but the the game was better off without it.

The latest iteration uses props from the current mission as objects to "search". There is a chance of finding something advantageous like extra ammo and landmines, at the risk of uncovering temporary setbacks like weakened defenses and stronger zombies.

It took a bit of effort to squeeze everything onto the screen. I could not write the names of the battle modifiers and the descriptions because it was just too much text on the screen. Also to prevent the player from forgetting the modifiers, sequentially I present each one being applied to the battle area with the description.

I found some good sound effects and utilized an existing particle effect. This feature now is more intriguing and cohesive with the rest of the game. 

It does take a bit of time to add in all those little movement transitions of the interface, but is well worth it. Corona helps make this easy through transitions with curved interpolation options. For example, the movement of the perks is "outExpo", meaning an exponential curve that starts very quickly and ends gradually.

Image by CoronaLabs
easing.inExpo ; easing.outExpo ; easing.inOutExpo ; easing.outInExpo
My general approach to game design is to offer a steady amount of progression of unlocked features, that is all polished with cool art, animations, special effects, and audio. If the game difficulty is balanced correctly, it can offer steady "fun" and keep the player engaged over time.

Friday, August 28, 2015

Zombie Guard

My latest project tentatively titled "Zombie Guard" at last nearly is completely finished!

Yes, there were delays to reach this point. It happens. There are many reasons, but importantly I made it to the end, so I am relieved! I'll write more info in the next post.. in the meantime, here are some screenshots:

Saturday, May 16, 2015

Clown speedpaint

There was a day I was absolutely disgusted by Adobe Flash for drawing and animation purposes. I found the timeline to be cumbersome, zoom and brush size options to be perplexing, and the line tool to be finicky. Well, I still find the line tool to be finicky... I choose not to use it. Nonetheless, the program is something I have come to embrace.

I like to rapidly swap between the brush tool and eraser tool. I like to "sculpt" objects and characters by constantly erasing and redrawing pieces, then duplicating and iterating until I find a sketch worth inking and shading.

Basically I always sketch before inking. It makes the whole process much easier. It is appropriate to rush each sketch, being very sloppy, as the entire purpose is to see a preview of what could be finalized. For this style, shapes are more important than lines.

In the coming weeks I would like to explore new mediums, such as water colors and oil paints. Every now and then I emphasize a particular branch that game development offers, from art, programming, design, to audio. Trying new things is the only way to grow.

Tuesday, April 21, 2015

How I Escaped the Dungeon of Torment

This past weekend was Ludum Dare #32! This is my "compo" entry, where the rules were to make a game in 48 hours, including all art, audio, and virtually all the code, centered around the top-voted theme: "Unconventional Weapon".

I make a strong attempt to participate in every game jam that comes along. It's a refreshing experience. This one, titled "How I Escaped the Dungeon of Torment" takes place inside a dungeon with treasure chests scattered, filled with marvelous weapon attachments such as jagged swords and druid vases. When the hero attaches each piece to his whip, the stats of the weapon are modified; the goal is to escape the dungeon by forcing open the door.

Oh wait. The dungeon actually is a storage shed. Those treasure chests are just boxes filled with random hardware tools and accessories. The hero attempting to escape, is just a child with an expansive imagination, writing in a diary as if being an epic fantasy tale.

Tuesday, March 24, 2015

The rise of roguelikes

Roguelike is a game genre featuring semi random procedural level generation, permanent death, events, often turn based gameplay, and sometimes progression between each session. They have become substantially popular in the past few years.

Some of my favorites include these:

Faster Than Light

The Binding of Isaac: Rebirth

Dungelot 2

Don't Starve

Cardinal Quest 2

Play sessions for these tend to average about an hour. There is a strong incentive to return and play again, since doing well in a session can lead to bonuses and permanently unlocked features.

I have really gravitated towards games like these. The incredible balance of the difficulty curves, the randomness, the thrill of progress.

Come to think about it, this style of game has been around for a while, perhaps just labeled as action or adventure rather than something more specific. For example, my first exposure to roguelikes was this classic gem for Sega Genesis called ToeJam & Earl:

ToeJam & Earl (image from

Albeit, features lives instead of strict permanent death.

My attempts to pursue this kind of direction as a designer have only moderately succeeded at best. For example, Demons Down Under was intended to be a challenging and unforgiving roguelike; eventually it was reduced to a more casual design to conserve time and widen the appeal to the larger casual gaming crowd on the web. It was still successful, just not what I had in mind. I notice my current zombie defense project following a similar direction towards casual design.

It can be easy to neglect some aspect of game development in promotion of another. Design, tech, art. I recall a decade ago, only stressing tech and programming. My games were more tech demos than anything. Afterwards came traditional and digital art, which led me to Flash game development. Now I want to stress design later this year, prioritizing it before the other two. I picked up this book by Jesse Schell on the Art of Game Design which covers a lot of excellent material. I call it the bible of game design.

I'm going to heavily stress usage of the book for the upcoming Ludum Dare game jam in April.

Friday, March 6, 2015

Corona SDK is now FREE!

The engine I use for mobile apps just became free! At least for all the essential features, such as in-app purchases, that used to cost an annual subscription in the hundreds of dollars.

As announced at GDC, Corona Labs is planning to expand its engine by building executables for the PC and Mac desktop gaming space. Well.. it's about time..?! The simulator already runs on both operating systems, so I can't imagine it being that much of an effort to build executables for these two. If additionally it could build for HTML5, then it would be very difficult for me to justify using anything else.

This is a very competitive year for mobile engine technology. Epic recently announced that Unreal Engine 4 is now "free" for 5% gross revenues. Meanwhile the personal edition of the recently announced Unity 5 is free with fair limitations.

Most likely I will opt for Unity this year, seeing that more and more web gaming portals are supporting it. Flash will continue to be the more popular option for the web, at least for the next five years. I will continue using it for game jams and art assets.