Developer's blog

Instant GUI editor

Tom, March 25 2008
My experiments with SWT have been pretty much fruitless. Initially I wanted to use SWT for all content editing tools - the level editors, sprite editors and possibly more interactive tools if things went well.

I did manage to get a LWJGL game up and running inside a SWT window and make it handle input and rendering without major problems but I realised that building a fully fledged level editor using SWT would be a very time consuming task. Not a time saver at all!


SWT with a LWJGL view inside.

I needed something more agile. So I turned my attention back to the basics. I was already using the principles of the Immediate mode GUI, as described in the infamous Molly Rocket video (mollyrocket.com/forums/vie…), so I decided to work further in that direction. The code was pretty rough, since it had been used only for very basic UI elements so far.

The most time consuming task had always been arranging various buttons, inputs, frames and other widgets on the screen. An endless cycle of adjusting values in Java code and restarting the game to see the results. Edit, restart, edit, restart. Very boring!

The first thing I did was to add code that used roughly estimated hard-coded values as defaults and saved them into a text file at the same time. Next time it would load these values from the file and ignore the defaults. That's a pretty pointless change by itself since it just moves the hard-coded values from Java code into the text file. But wait.

The second thing I did was to add a global keyboard shortcut that activated the new "layout editing mode". This mode disables the default behaviour of all widgets and turns them into dumb draggable rectangles. Mouse dragging moves, shift-drag changes the dimensions and another hotkey saves the layout back into the file.

Here's a chunk of pseudo-code to show what happens. First the default behaviour:



And this happens when the editing mode is enabled:



And that's pretty much it. The real code is about 300 lines, including support for unlimited undo/redo. I can now adjust any part of the UI directly inside the game, with instant feedback. Even if it's an custom animated bobbing button above a game character's head - as long as it uses the Button.process() routine to register mouse clicks, I can press F4 and edit it in realtime, while the game is still running. Neat, isn't it?

Using Javascript to write OpenGL apps

Tom, March 23 2008
This quick test shows that using Rhino it is possible to call LWJGL functions from Javascript programs. It might be useful for quickly testing OpenGL snippets or writing cool tiny games.


John Carmack would be proud.

Nowadays it's possible to glue almost any two languages together and use one to control the other or use it's libraries. When investigating the TinyCC compiler I wrote about last time, I was amazed to find a Python module that uses TinyCC to compile and run C code on multiple platforms. That means that it's not only possible to script C programs using Python (with Boost::Python or whatever) but also to script Python programs using C!

You can try the Rhino example yourself - get this 3MB package with source code and all dependencies. Don't forget to add -Djava.library.path=lwjgl-1.1.4/native/win32 to the VM arguments - or import this Eclipse launch configuration which will do that for you.

Pointless tinkering with TinyCC

Tom, March 21 2008 (3 comments)
What could possibly be more geeky than taking a perfectly working win32 Java launcher and taking several hours to replace it with a different one just to save sixty kilobytes in a twenty megabyte game?

Nothing!

So I did it and it turned out to be very satisfying. After all, how could I resist using a compiler called TinyCC? Tiny means good, optimized, fast, superior. Always! It looks like TinyCC comes from the good old days, when programmers wrote efficient code and things were generally better, blah blah.

Anyway, TinyCC is a very very fast C compiler that can produce very very small EXE files. It is so fast that some people have used it to compile and boot the Linux kernel in 15 seconds, which I think is fairly impressive, as much as compiling the linux kernel can ever be. Fifteen seconds. I mean, what can you do in that time? Look out of the window and sigh?

TinyCC: fabrice.bellard.free.fr/tc…

The only problem with TinyCC is that it's linker is very basic so you cannot just tell it to embed an Icon resource into the EXE.

And you wouldn't believe how hard it is to add an icon to an existing EXE file from the command line. I ended up using two different utilities to do the job, ResHacker to import the icon inside the EXE file and IconInjector to fix it so Windows can actually pick it up and display it in Explorer. Now it all works fine as part of the build script and I no longer need to keep Visual Studio around just to change the icon. Woohoo! Now, on to things that actually matter...

Fatally wounded

Tom, March 17 2008
Ha! Violence. I knew it would catch your attention. Another internet discovery that made me smile - six minutes of every Mortal Kombat fatality in existence. Observe:



Video link: www.gamesradar.com/gc/mort…

Oh! Fez!

Tom, March 16 2008
I just discovered and fell in love with a beautiful piece of pixel goodness called Fez. It is being created by Phil Fish of the Kokoromi collective based in Montreal.



A picture makes it no justice though, you HAVE to see it in motion.




No demo yet, but it is definitely something to look forward to. The Kokoromi site has more footage and info: www.kokoromi.org/fez and here is a great interview with Phil: tinyurl.com/3ywqf2
Games
Devastro
Titan Attacks
Chocolate Castle
Shop
Buy Devastro
Buy more games
Newsletter
Subscribe
Unsubscribe
Blog
Latest posts
Browse all posts
Subscribe to feed
Contact
Contact us
Feedback form
Game name generator