Linking assets between desktop and android project in libgdx

Here is a little tip you might find useful when working with two different eclipse projects in your libgdx project.

It is a common scenario to have multiple assets like sounds, textures, animations etc. which you want to reference in your desktop project and in you android project. The simplest way to solve this problem is to simply copy the content in each project but this causes constant work as you need to keep those two in sync.

When on linux, one possible solution is to create a symlink from one assets folder to the other. That works fine but does not work on every platform. Another approach is to create a resource link inside eclipse. This only works when starting your project from within eclipse and is of course not honored by a continuous build system you might use. Additional measures are required (like actually copying the assets or symlinking).

Here is how linking in eclipse is done. Place all you assets in the assets folder of your android project (the assets folder is a prerequisite for an android project). Next open your file explorer. Go to the android project and drag the assets folder from the android project to you desktop project inside eclipse. Eclipse will ask you to either copy, link or link and recreate the folder structure. We choose to link.

When you start your android project it finds the resource because they are physically in your android project and when starting the desktop project, the link allows eclipse to gather the assets from the android project. The cool thing is that eclipse is realizing, that the source assets folder is in the workspace and therefore creates the link relative to the workspace root. That means you can share this linked config accross multiple dev systems with different folder structures. Hope this helps.

Racing Game Prototype

I threw together a quick prototype of a small racing game i want to have finished by the end of february. It’s similar to donut games’ awesome Comet Racer, a top down 2D racing game with nice pixel graphics. Here’s a grainy video of the prototype in action:

and here’s a screenshot:

You can try out the prototype by installing this apk. You can accelerate the ship via any key except the home/back/menu/search keys (trackball works too). You steer the ship via the two on-screen buttons. It does not work to well yet on G1/Hero kinda hardware due to touch events flooding the system (and yes, i sleep in onTouch, does not solve the problem). I consider publishing this for android >= 2.0 only as the problems on devices with a lower android version bug the crap out of me. Especially the event flooding and associated garbage collection sucks big times and it’s just not possible to get a smooth game experience which is essential for a racing game.

I only have the tile map rendering, controlls and collision detection down yet. An editor is currently in the works. I plan on adding quiet some features to this racer, the basic premise of it will be time trials. You’ll be able to race against your own ghost of the best race you completed on a map as well as against ghosts of other players that submitted their race for others to compete against. I’m currently thinking about adding an upgrade system so you get a better and better racer over the course of the game. However, this will make comparing highscores a bit harder as the leaderboards will be lead by people that fully upgraded their racing vehicle.

On a technical side it’s a tilemap engine where layers are positioned in 3D space. There’s a parallax background and a collideable foreground at the moment. The ship is a 3D model. Other objects in the game will also be 3D models, e.g. lasers, items, triggers and so on, to give the game a bit more a 2.5dish look. On my droid it achieves around 40fps which is ok. 60fps on the droid doesn’t seem to be achievable due to fillrate issues. I employ a simple culling scheme for the tilemap so i can basically have infinitely big maps. The same is true for culling objects. Only the simulation logic is executed for visible and none visible objects for obvious reasons. This code is pretty simple so it does not bog down the game the least.

Drop me a line if you have ideas for features to be included and report any problems you have with the apk above if you try it!

Newton In-Game Editor

Last weekend i started integrating the desktop editor for Newton into the android version (yes, there’s a desktop version of Newton too, using the same exact code). I was initially a bit afraid that the editor is to fiddly to work on the small screen of say the hero or G1 (didn’t test on tattoo). However, my fears have vanished. The editor is now in a fully functional state along with a dead simple way to upload and share your levels with others. I recorded a small video showing of the editor in action:

Sorry for the bad video quality, i need to get a new webcam. This one hasn’t been in action for a bout 3 years :p.

The video shows of the intuitive interface of the editor (at least i think it is intuitive). Just drag and drop any item on screen. To create a new obstacle select the respective button at the bottom (the green one) and draw the corner points of the obstacle. You can also easily animate obstacles via a time slider shown at the top of the screen. Once you feel like the level is ready for some testing you can do a try run of it via pressing the run button. Pressing the back button in the run screen brings you back to the editor and the map you just edited. If you feel confident enough that your level is awesome you can either save it to your local sd card or directly upload it to the server from where other users can download, play and score points on your map.

To get to play maps created by others you simply go to the level selection menu, chose online levels and start playing any map you like. Highscores are of course also recorded for user generated maps.

Now we are busy creating the levels for the final version. Stefanie will (hopefully! /me shakes fist!) do most of that work, so blame here if a level really pisses you off :). We will probably not make the planned release date this sunday and instead aim at some time next week. The levels should be worth the small amount of money you’ll hopefully spent.

Leave your thoughts in the comments!