Writing Games with Processing: Getting Started

15. December, 2013

Ever wanted to write your own game? Can’t be too hard, right?

Most games sold today are ego shooters. But the genre is sucked pretty dry. The most innovative games in the last years were simple, surprising and cheap. Examples are BraidFez, Thomas Was Alone. Those games didn’t thrive from multi-million development budgets, they throve from simple ideas. They were great not despite but because of their limitations.

In this series of blog posts, I’ll show you how to develop a very simple game using Processing.

Processing is a simple environment to create amazing computer generated images using a simplified version of Java like the one on the right (code).

Komplexe Methoden –  M.1 Zufall und Rauschen –  M.1.6 Agenten im Raum –  M_1_6_01_TOOL

Komplexe Methoden – M.1 Zufall und Rauschen – M.1.6 Agenten im Raum – M_1_6_01_TOOL

While you download the software, we need an idea.

In my case, the idea came from a brainstorming session organized by Zurich Game Developers at the MechArtLab. Everyone had to buy a Kinder Surprise egg (illegal in the USA, btw.) and create a game with the content. The eggs in my group contained a platypus, a crocodile and a frog.

After a quick brainstorming session we came up with this game idea: “Kribbit, the frog, runs a zoo. A small zoo. A very small zoo. Only a single compound. He has two animals: A poor, lonely platypus and a couple of crocodiles. The crocodiles promised to be nice to the platypus and not to eat him. But every time Kribbit looks the other way, the crocodiles try to eat poor Platty.”

That’s it. Game idea? Check.

What? Too simple for you? Well, complex game = low chance of success.

Next post: Setup and a simple player character.

Anomaly – Warzone Earth

21. September, 2012

Anomaly – Warzone Earth (forum) is basically a reverse tower-defense game. The computer builds the towers and you try to get past them.

The game works on Linux, Mac and Windows. Installation on Linux 64-bit was painless: just unpack the archive and execute the game.

By default, it runs in full-screen mode which is a bit of a problem for me since I have two screens. Alt+Enter toggles between full-screen and windowed mode.

Your goal is to lead a train of 5 armored vehicles through a dangerous area. You can heal the vehicles, give them directions, change their order, add and remove units. In later stages, you will get decoys that draw enemy fire, or smoke grenades that cover your for a time.

Some tactical tips:

  • Don’t rush. In most levels, you have lots of time.
  • Crawlers have a slightly higher range than the basic enemy towers. If you circle an adjacent city block, you can often take out some of the enemies with little or no damage at all.
  • Heal units using corners. Place the repair item in the corner and four units will be in range instead of the normal three.
  • If you need to heal the leading unit, place the repair token a bit ahead so the unit gets enough exposure.
  • Keep an eye on health. If a unit is losing a lot of health and you can’t reach it or you’re out of repair tokens, you can put them in a different place in the train. If the first or last unit is out of range, move the damaged unit there. Losses are really expensive in this game.
  • Try to clear all enemies. In the first levels, supplies will be dropped anywhere but soon, they will be dropped after destroying enemy towers. Plus, each kill gives you a bit of money that you should spend on more units or upgrading existing ones.
  • The first unit takes most damage. Upgrade it first.
  • When a unit is under attack, you can cancel the effects by dropping a repair token.
  • If you walk in circles around the basic towers, they will aim at you. That way, you can buy your tanks an extra moment since the turret will first have to turn back before it can open fire.
  • Plan ahead. The closest reward might not be the easiest. Try to single out towers. Drive past and out of range to repair or recharge shields.
  • Each tower has a specific weakness. Exploit them.
  • Some can’t turn. Don’t attack them head on; drive by instead or kill it from behind.
  • Behemoths do area damage. Use a decoy and place it far away from your units.
  • When you need to squeeze through a bunch of towers, use a smoke bomb.
  • Decoys work well with flash towers but you need to place it at a distance or the damage will spill.


Journey (PS3)

17. March, 2012

Bored by the violence in Mass Effect 3? Solved Ratchet & Clank three times already?

How about a nice, relaxing Journey?

Journey is the latest … uh … game? by thatgamecompany. Remember flOw? Flower? If you already own those two, Journey is for you. If you don’t – give it a try. Discover the journey.

Glorious Sunrise in Minecraft

7. April, 2011

I’m working on my crystal tower. While roaming the country, I stumbled over this cliff (Minecraft Beta 1.4):

Numpty Physics

17. March, 2011

I really liked Crayon Physics. It was simple idea, great brain teaser, the perfect UI.

If you liked it as well, have a look at Numpty Physics.

Mass Effect 2 for PS3

6. February, 2011

I started playing Mass Effect 2 for the PS3. Nice game.

Dear EA: Console users want to play, not listen 1 hour for an installer to scrub the game disk with the read/write head. Hint: Other games show an elaborate intro while installing, not instead of installing.

Also, there is no turbo in the elevator; loading times in the ship itself could be much better. Fortunately, running around in the ship is only necessary in the early stages of the game.

Collecting shady individuals from all over the galaxy and poking planets for resources is quite some fun; I just wish the shooting sequences were not so dominant. Luckily, that seems to get better later in the game where you can roam space stations, break into walk-in safes of criminals, etc.

All in all, quite some fun.

Updating StarCraft 2 to 1.0.3 on openSUSE 11.3 SOLVED

19. August, 2010
A Protoss warrior, as displayed in StarCraft II.

A Protoss warrior, as displayed in StarCraft II. (Image via Wikipedia)

I had a lot of problems to download and install the patch to 1.0.3. Here is my solution after 144 failed attempts: Install IE6! The BlizzardDownloader.exe doesn’t work with the IE emulator (gecko) so use winetricks or /opt/cxgames/bin/cxinstaller to install IE6 instead and it won’t crash anymore.

Hint: The crash happens somewhere in the JavaScript DLL js3250:

=>0 0x0245b44c in js3250 (+0xfb44c) (0x0033b4b8)
  1 0x0245b2e6 in js3250 (+0xfb2e5) (0x0033b4d8)
  2 0x02459d62 in js3250 (+0xf9d61) (0x0033b4f8)
  3 0x023fc423 in js3250 (+0x9c422) (0x0033b548)
  4 0x01025b6a (0x0033b594)
  5 0x0033df84 (0x0033df84)
  6 0x02420b5a in js3250 (+0xc0b59) (0x0033dfd4)
  7 0x0239f43d in js3250 (+0x3f43c) (0x0033e1f4)
  8 0x023b21bb in js3250 (+0x521ba) (0x0033e2a4)
  9 0x02368391 in js3250 (+0x8390) (0x0033e2e4)
  10 0x0164c6e5 in xul (+0x5cc6e4) (0x0033e3a4)
  11 0x014eaf8d in xul (+0x46af8c) (0x0033e4e4)
  12 0x014eaa7b in xul (+0x46aa7a) (0x0033e5c4)
  13 0x014ea1c6 in xul (+0x46a1c5) (0x0033ea14)
  14 0x014e7cad in xul (+0x467cac) (0x0033ea74)
  15 0x0156ca4b in xul (+0x4eca4a) (0x0033eb54)
  31 0x01c634e4 in xul (+0xbe34e3) (0x0033ef44)
  32 0x01c0b086 in xul (+0xb8b085) (0x0033ef74)
  33 0x01bd77ce in xul (+0xb577cd) (0x0033ef94)
  34 0x7eccecfa WINPROC_wrapper+0x19() in user32 (0x0033efc4)
  35 0x7ecd0819 in user32 (+0xa0818) (0x0033f004)
  36 0x7ecd1cac in user32 (+0xa1cab) (0x0033f044)
  37 0x7ec9541e DispatchMessageW+0x9d() in user32 (0x0033f134)
  38 0x7ec660b9 in user32 (+0x360b8) (0x0033f194)
  39 0x7ec6626f DialogBoxParamW+0x8e() in user32 (0x0033f1b4)
  40 0x00406156 in blizzarddownloader (+0x6155) (0x0033fd84)
  41 0x7e725b64 in ole32 (+0xd5b63) (0x004cd07c)
  42 0x6b735a42 (0x0044303a)
  43 0xfffffec2 (0xe8f18b56)

Look for “xul” and “js3250” in the stack trace. If you use cxgames, start the game with

"$HOME/.cxgames/Starcraft II_ Wings of Liberty/desktopdata/cxmenu/StartMenu.C^5E3A^5Fusers^5FPublic^5FStart^2BMenu/Programs/StarCraft+II/StarCraft+II"

If you need to kill the game, use this line:

kill $(ps -e -o "%p:%a" | grep -E 'winewrapper.exe|wineserver|system32|StarCraft|winedbg|Blizzard'|grep -v grep|cut -d: -f1)

That should get rid of all leftover processes.

[Update] I sometimes get a window asking where to store a download. Ignore it; it closes eventually. Click outside of it, it if bothers you to hide it behind the update manager window.

StarCraft 2 on openSUSE 11.3 [update]

13. August, 2010

As you may have heard, StarCraft 2 works on Linux. It’s even officially supported by CrossOver Games. It’s only Silver (which means “runs with minor issues”.

One of the issues is that the game crashes at startup or shortly afterwards. This seems to be a kernel bug.

To solve the issue on openSUSE 11.3, you need to install a kernel with version 2.6.35. Luckily this is pretty simple:

  1. Add the repository http://download.opensuse.org/repositories/Kernel:/HEAD/openSUSE_Factory/  with Yast2 (under “Software Repositories”). Give it any name you like.
  2. I suggest to set the priority to 120; that way, the other repositories will be considered first and entries in this new repository won’t pollute your system unless you ask for them.
  3. Open “Software Management” in Yast2
  4. Open the tab “Repositories”
  5. Select the new kernel repository
  6. Locate the package “kernel-desktop” and select it
  7. Click on the “Versions” tab at the bottom
  8. Select the one with version “” (the last digit can be different).
  9. Click “Accept”

Yast2 will download the new kernel and install it. After a reboot, you can enjoy StarCraft II.

[Update] I’ve played the first six single player missions and had no major problems so far. The frame rate could be better but that’s about it.

[Update 2, 11th Nov. 2010] Kernel 2.6.36 has been released. You can find it here.

“Good” Game

7. January, 2010

Reading “The Problem of Good, in a Platform Game” got me thinking.

I doubt some of the assumptions on that page and I’d like to present my own here. It should be possible to model them into a simple agent for a game as well.

First, let’s assume that resources are finite and somewhat scarce. Changing your alignment (good/bad) need resources, so you won’t do it on a whim. I’d even say that there is a hysteresis, so you stay in your current alignment longer than in a perfect (linear) world.

So the question is: What changes you alignment?

My theory is that several forces influence your alignment (not necessarily in this order):

– Peer pressure
– Personal experience
– Prediction of the future
– Food/rest

Some comments on these forces:

1. If everyone around you is good, it’s hard to become evil, partly because they will fight this tendency, partly because you simply have no role model. We are all mimics. It’s hard to come up with something new on your own (again scarce resources: You don’t have all the time of the world nor can you change as often as you like).

You might argue that some people are born evil. I’d like to have proof of this, please.

2. Whenever you get into a situation X, you will rake your memory for similar situations to give you a guideline how to respond (again scarce resources). So if your experience tells you to be good in situation X (because that worked in the past), you will be good. Notice that only the outcome of the situation for *you* counts. So if you like to whine about being capitalized, the outcome of being abused is “good” for you – no need to get your lazy bum up and change.

3. If the situation is new, you have to come up with a plan. Again, you can’t think for years, there is some pressure on you. So the plan is never perfect and you will know that. So depending on your confidence of your plan, you will change your alignment or stay on safe (known) ground.

4. Most people are only civilized as long as they are fed and well rested. Just imagine to deprive someone from sleep for a day. They will get irritated much faster than a well rested person.


0 is neutal, > 0 is good, < 0 is selfish

1. is fairly easy to model: Just sum the influence of the people around you. Maybe multiply that with a factor depending on the psychological distance the people currently have to you. That is, your role models will feel pretty close even if they are on the other side of the globe while your neighbor could be on the other side of the moon, you couldn’t care less.

2. For every game situation, you need to calculate the net result. Use several standard games (prisoner dilemma and a couple more) and store the factors and the result in a memory per agent. When the next situation comes up, compare the setting with the memory and have the agent change its alignment according to the expected outcome of the game. When this is done, the agent is ready to play the game. Update the memory afterwards.

If the result is off the scale, change the alignment accordingly.

3. For every new game, have the agent play a few rounds against itself. Use the result as the alignment for the game. If the outcome is vastly different from what the agent expected, multiply this "unsureness" factor to the alignment change (if we’re more insecure, we are more susceptible for influence).

4. Give the agent a head and a stomach. Let them rest, eat (and work late and starve). 0 means "normal", 0 means rested/well fed. Scale this accordingly (maybe this is even logarithmic: If you are very hungry, you’ll even eat another agent) and add to the current alignment.

To map the linear alignment to the “good/selfish” alignment, use a hysteresis curve. The final result should show some “resistance” to change the current alignment and a preference to return to the current state (so if you’re currently selfish, being treated nice won’t count as much as being treated badly).

Batman: Arkham Asylum (PS3)

24. August, 2009

Even for the many definitions of fun. For example, there is a new game “Batman: Arkham Asylum”. I was really hesitant to download the demo. And then, I was hesitant to install it. Why? Because the trailer gave me the impression “another super hero beat ’em up”.

Okay, the in game cut scenes look great. Clothes have texture and the outline of the characters doesn’t reveal the 17-poly mesh. During the demo, it quickly becomes evident that a lot of resources went into the combat scenes where Batman does move pretty smart. You select a general direction and the type of attack and the Bat will do some serious damage. It feels like you actually control someone who spent years training martial arts, not some stuffed puppet. Using the grappling hook works like charm, even without much aiming. It’s enough to be close one of the gargoyles and it’ll work like a charm. Well … gargoyles in the building? Anyway.

That changes when you start walking around the compound. Here, the stuffed puppet is back. You can run which makes things better but the walk cycle looks really unbelievable. Did you know that Batman can’t jump? Maybe it’s because of the heavy belt? Or the muscles are all part of the suit’s armor? No climbing either. If you don’t have something where your grappling hook can attach to, you can’t even climb on a chair.

But what I was most afraid of: “The world’s greatest detective.” Remember? After taking the first round of inmates down, I almost gave up on the game. Only it does get better. There is something called “detective mode” which highlights interesting features around you (like enemies, things you can use your grappling hook on, etc). So after the short scene with Victor, the game turns into something that resembles Metal Gear Solid. Not bad. While you can try to take down everyone with a gun, you probably shouldn’t. Just as in reality, when you beat up one out of five people, four will start shooting you in the back.

There is still hope.