Category Archives: News

1 day workweek

I had a promising game prototype for about two years. It was just lying there… I wanted to turn it into a full game but I just didn’t have enough time and energy to do it. I spent long hours each night trying to move it forward but I was just too tired. It wasn’t going anywhere.

In Spring 2014 I decided to reserve one day of the week to work on my game. So each Friday, instead of commuting to my regular job, I go upstairs into my home office and work on Superforce all day long.

Home office

So far I count 16 Fridays. It’s a cool setup and the game is now progressing really well. There’s no stress. I get up in the morning, fresh and with a full day of game development ahead of me. Good times. Big love & thanks to my wife for supporting this endeavour.

I don’t want to call myself an indie. To me, being independent now means something else than it used to. It’s not about making enough money from games to be able to do it fulltime. I tried to achieve that and it didn’t work out for me. But even if it did, I’d have to work really hard just to keep it that way and that would spoil the fun. When it comes to game development, I am now as independent as I can ever be. Will the game sell? It would be nice but I don’t depend on it. I’m an amateur. A hobbyist. And I’m happy.

NLEngine

As I wrote in my previous post, I’m using C++ to write Superforce. I had to unlearn a lot of Java habits and get up to speed with C++ again. C++ is much more powerful and expressive than Java. Not having garbage collection actually helps me write better code. The C++11 update is great.

Great to be back
Hello C++, it’s great to be back

I didn’t want to use a 3rd party engine for the same reasons I stopped using Java. I want to be in control of the core technology and I want to build it myself exactly the way I need. So even before writing any game code, I built an engine.

NLEngine is what I call it. Nice Little Engine. Don’t laugh, it’s a separate project in Xcode, so I had to give it a name, OK? And “Source” was already taken. Shut up! Anyway, it is aimed at 2D action games. I’d love to build a few with it and Superforce will be the first one. The overall goals are:

  1. Ease of use
  2. Simplicity in design
  3. Reasonable performance

So far it does the following things:

  • Sprite renderer with batching
  • Sound playback with ogg streaming, OpenAL output
  • Reading touch, accelerometer, mouse, keyboard input
  • File I/O, can use mmap, supports PAK files
  • Image loading
  • Fonts
  • Geometry utilities, cameras
  • Scene management with transitions
  • Texture atlas
  • Tile maps with material masks
  • Particles
  • Animations such as fade, rotate, scale, move etc. with easing curves
  • Timers – realtime, fixed step and a scoped timer for quick performance profiling
  • IMGUI
  • Undo/redo history (for editing tools)
  • SQLite wrapper (for keeping game stats, highscores etc)

External dependencies are kept to a minimum: stb image, stb vorbis, rapidxml, sqlite. I do use the STL but stay away from Boost.

It uses OpenGL which is good enough for now. I’m just blasting sprites on the screen. I’m looking forward to using more modern graphics APIs but right now I feel it would be too much new stuff at once.

It runs on iOS and Mac OS X. There’s a good chance I’ll get it to run on Linux. Later I might look at the Android NDK, but I’m not sure what to think of the absence of OpenAL there. Windows port is not planned.

All game code is written in C++. I don’t want to use a scripting language and rather focus on designing good APIs and abstractions in C++. Sooner or later taking care of the bindings for a scripting language would become too complex for me. If I absolutely had to pick a scripting language, it would be Lua.

From Java to C++

My previous games used Java and LWJGL but I decided to make a big change and leave Java behind.

Superforce is written in C++.

When I started making games, I thought Java was a good choice. It is a nice language. I know it really well. The IDEs are super powerful and garbage collection usually doesn’t hurt too much.

But when the iPhone and the App Store appeared and started gaining momentum, Java left me out in the cold. First, I was just disappointed. Perhaps they would add Java support in a few months. But it didn’t happen. Disaster.

It wasn’t an easy decision to change my main technology. I took it very seriously. After completing two games, I had a lot of reusable code which seemed valuable. But I knew needed something solid that really does run everywhere.

So for Superforce, I quite literally started from scratch. Clicked Xcode > File > New Project and started rewriting my engine in C++.

NLTemplate – HTML template library for C++

Don’t ask me why, but I needed a simple HTML template library for C++. I looked at a few of them, but there wasn’t a clear winner. Most were too heavyweight, hard to build or I didn’t like the syntax.

So I decided to write my own. How hard can it be?

NLTemplate is really simple. It comes in a single source file, has no extra dependencies and you can just drop it in your project and it will work. It does variable replacement, optional or repeatable blocks and file includes. You can define your own file loader to deal with path resolution and file I/O. To insert a variable, you write {{ variable }}, to define a block, you write {% block name %} and then end it with {% endblock %}.

Get the source code here.

Tempo, a PHP static site generator

I got tired of the constant Tumblr outages and keeping a Django site up and running seemed like too much work, so I made Tempo. Tempo is a small static site generator written in PHP. I use it for this site and will probably use it for some others in the future. It takes

  • A small PHP config file
  • Text files with a simple header
  • Source images of any size
  • PHP-based templates

and transforms them into a static html site. It can

  • Resize images to fit the specified page width
  • Create a blog archive listing page and an Atom feed
  • Skip “draft” posts (filenames that start with #)
  • …not much else, really. Isn’t that enough?

URLs are built like this:

about.txt becomes about.html
blog-2011-10-10-blog post title.txt becomes blog/2011/10/10/blog-post-title.html
etc.

For text formatting, just use HTML tags. URLs starting with http:// are automatically converted into links.

Get the source code here.

Simple tilemap collision mask editor

To try out pygame, I wrote a simple editor in it. It is nice to see what can be achieved with 100 lines of Python. I wouldn’t necessarily choose it to write an entire game, but for a simple interactive tool or a prototype, it is nice.

This simple editor opens a tileset image and lets you edit its collision mask. Use case: you have large graphical tiles but want them to have a more fine grained collision mask. For example, the graphical tiles are 128×128 but you want the collision mask to be 32×32.

Download TilemapMaskEdit.py (requires Python and pygame)
Example tileset from Devastro: water01_128.png (do not use this asset without permission!)

To start it, run python TilemapMaskEdit.py water01_128.png. Draw the with left mouse button, erase with right, F2 = save to .txt. This would be water01_128.png.txt in the aforementioned example.

The output file format is very simple.

[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]
[0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0]

Simple TMX tilemap parser

Here’s a simple C++ class for loading tile map data from TMX files produced by the Tiled map editor. Contains Xcode project with demo.

USAGE:

NLTmxMap* map = NLLoadTmxMap( "map1.tmx" );
std::cout << map->width << " x " << map->height << std::endl;
delete map;

Download the project here.

LIMITATION: you need to select “CSV” map data encoding in Tiled preferences. I didn’t bother with decoding the base64/gzip formats that Tiled also supports.

Java game development

Java had the potential to be a very good platform for game development.

A garbage collected language significantly cuts down development time. The editing and refactoring tools are fantastic. Compilation is lighting fast. Debugging is easy. There are solid OpenGL and OpenAL bindings available. Runtime performance is fine.

Java runs on many platforms and it is not at all a bad choice for any of them. But it is not the right choice for any, either.

None of the major platforms now comes with a JRE preinstalled. The Windows installer is a mess, the future of the Mac implementation is uncertain. Java is not available to developers on any of the console platforms and the only mobile platform that sort of supports Java programming is Android.

There is no standard way of making a Mac app bundle out of a Java program. There is no standard way of making a Windows installer or executable out of a Java program. You have to do everything by yourself. Write Ant build scripts, make NSIS installers, EXE launchers, Mac app bundles, program icons. There is NO official support for this.

Here is a list of things I think could help:

  • Get rid of jusched.exe. Use the standard Windows scheduling service like everyone else. Even Google eventually got that right with their update service.
  • Get rid of tray icon.
  • Allow custom JREs to be bundled with software products. The current license doesn’t allow me to go into rt.jar and remove the 90% of stuff my games don’t use. A 50MB game is inflated by 100% by the standard Java libraries.
  • Add a standard way to make an EXE file / Mac bundle / Linux binary that launches a Java program. CMD/BAT/SH files look amateurish and cannot have icons.
  • Make it super easy to create an embedded version of the JRE, cut down to just the stuff the program uses, ready to go. In fact, embedding the VM and the libraries and the Java program itself all in a single EXE file automatically would be the best way to do this.
  • Make Swing use native controls for everything. Or switch to SWT and get behind it 100%.
  • Get rid of the stupid mascot creature and pretend it never existed.
  • Remove Java Sound. It is a bunch of complex unusable interfaces written by architecture astronauts. Nobody uses it.
  • Use a sane versioning scheme. Java 6.0.21. Oh, and, you know, stick to it from then on.
  • Open up the new self-updating mechanism so that any Java program can use it to update itself from its developer’s site.
  • Make it easy to retrieve the proper location of users’ home directories. Documents, Pictures, App Data, stuff like that.
  • Merge server and client JVMs into one. It is confusing.