Baseline Eclipse for Java Game Development?

The Eclipse IDE as it is offered for download at has become quite large. Size in bytes is probably not the biggest issue, but I think some of the functionality showing up in the UI is unnecessary clutter for many purposes that Eclipse could be used for. One such purpose I’m personally interested in is game development on the Java Platform (using Scala, Java, or another JVM language).

Some Java game development tools are already being built as Eclipse plug-ins and most likely more will be in the future. But right now they must provide them as a plug-in for an existing Eclipse installation that has all the clutter or build a completely custom Eclipse-based application, possibly an RCP app that doesn’t even include the Java Tools. I think this shouldn’t have to be the case: users of Java game dev tools should be able to download a version of Eclipse that is freed (as much as possible) from the cruft that they will not need, and be able to install specific tools and engine specific libraries into that baseline game development environment.

So I’m thinking of creating a lighter distribution of Eclipse JDT + XML tools that removes rarely used features from the Eclipse for Java Developers distribution and is specifically geared towards game development rather than enterprise Java or application development. Perhaps this should also extend to C/C++, but I am not familiar with the CDT so I’m not considering that aspect right now.

This distribution shouldn’t come from of course, but rather from the open source game engine and tools developers. I am willing to work on such a project, as long as it provides actual value to game developers and doesn’t eat up too much of my time. The first version of it could be fairly basic, just a lighter distro of Eclipse. Later versions can start incorporating game dev specific tools and UI concepts. Is there anyone interested in contributing to such a project? Or using such a build of Eclipse? Please let me know.

The first step of the project should be to create a reduced version of Eclipse JDT + XML tools that is still updateable, so that game development plug-ins and plug-ins such as Scala IDE, M2Eclipse, Subclipse, EGit can be installed. I have done some initial experiments and found an approximate list of features that can be easily removed from Eclipse JDT. If you would be interested in using such a distribution, please comment what you would like to be kept:

  • APT or Annotation Processing Tool support — I think this is very rarely used and just clutters the UI in some screens.
  • Ant support — I think a lot of people would be against this, so it should probably stay
  • CVS support — CVS should not be used by anyone for other than legacy reasons, now that we have Git, Mercurial, SVN etc. And I expect that games development will not involve much poking around in legacy repositories. I think most open source game tools use SVN (correct me if I’m wrong).
  • Help — this is debatable, but I would remove it from the first version and decide later what to do with it
  • Welcome screen — same as help, can be added back later if it’s found to have some use
  • JUnit3 support — JUnit4 should be enough, I think
  • Various internal tools and plug-ins, backwards compatibility stuff

I’m estimating that the size of this distro would be somewhere between 50-70 MB. The P2 update manager included in Eclipse will increase the size on disk though, because it may create a lot of meta data and caches. But disk space is relatively cheap, and I don’t think there’s a better update manager available. My main concern is removing UI clutter so that game dev tools that plug into it will have more UI space and better visibility. Compared to the Eclipse IDE for Java Developers distribution, which lists the following “features” (feature in Eclipse terms is a collection of plug-ins):

  • org.eclipse.cvs
  • org.eclipse.epp.usagedata.feature
  • org.eclipse.equinox.p2.user.ui
  • org.eclipse.jdt
  • org.eclipse.mylyn.bugzilla_feature
  • org.eclipse.mylyn.context_feature
  • org.eclipse.mylyn.ide_feature
  • org.eclipse.mylyn.java_feature
  • org.eclipse.mylyn.wikitext_feature
  • org.eclipse.mylyn_feature
  • org.eclipse.platform
  • org.eclipse.rcp
  • org.eclipse.wst.xml_ui.feature

Only these would remain (and even those not in complete form):

  • org.eclipse.equinox.p2.user.ui (this is the update manager)
  • org.eclipse.jdt (custom lite version with APT and maybe a couple of more small things removed)
  • org.eclipse.platform (custom, with various plug-ins removed)
  • org.eclipse.rcp
  • org.eclipse.wst.xml_ui.feature (possibly custom with a couple of plug-ins removed)

Later versions could add optional updates that bundle engine-specific tools and libraries, Scala, SVN, Mercurial, Git or Maven support etc.

What do you think? Is there need for such an Eclipse distribution? I’m especially interested of the opinion of Eclipse based game tool developers, if any of you happen to read this post. Would you contribute if someone does the initial work? Has someone already done something like this (not engine specific)?

Call to JVM library developers: upload sources to Maven repos

I wish all developers that release libraries for the JVM platform (Java, Scala and other libraries) and put their libraries on Maven repos would also put the sources there. It makes it so much easier to get sources automatically attached in an IDE without going digging for them. Maven doesn’t do this by default, but building (and deploying) the sources Jar along with the binary Jar should be a matter of adding these settings to your library’s POM (or better yet, to a parent POM if you use a parent which defines commons settings).


ScalaBox2D is getting SVG support

ScalaBox2D is going to get an SVG scene importer soon. This will let you draw a scene in Inkscape and load it as a Box2D world in ScalaBox2D. I already pushed a very basic version of this to GitHub. It uses Slick‘s SVG parser and has many limitations as of now, but you can already draw a Scene like this:

SVG Drawing

Inkscape SVG drawing

And bring it to life in a ScalaBox2D application:

ScalaBox2D Scene

ScalaBox2D scene

Currently every circle, box or polygon that has a red (#ff0000) fill will be turned into a dynamic body, the rest will be static bodies. There are also some limitations to the shapes, including: polygons must be convex, and have at most 8 vertices (or they’ll become static edges). Ellipses/arcs are not supported, only circles. You may get exceptions when loading some shapes.

The goal right now is to make this as robust as possible, so you can run the ScalaBox2D testbed and load (almost) any SVG file saved by Inkscape into it. After that, I’ll add support for loading scenes from game code and tying the physical bodies to game objects.

The code for the app looks like this:

import org.villane.box2d.svg._
import org.villane.box2d.draw.DrawFlags._
import org.villane.box2d.testbed.slick._

object SVGApp {
  val scale = 15

  def main(args: Array[String]) {
    val loader = new SlickSVGSceneLoader("C:/drawing-1.svg", scale)
    val world = loader.create
    val flags = Shapes
    SlickDisplayWorld.runWithSimulation(world, false, flags)


ScalaBox2D Physics Engine source available

The source code for my Scala port of Box2D is now available at GitHub. There is not much support or documentation at the moment. For now, use only if you already know Box2D or really need a physics engine written in Scala :) More documentation and better user experience will be coming in the future.

I am working on the performance, but currently it is about two times slower than JBox2D (which you can also use from Scala).

Get the source code here. And a little information on how to build and run the testbed is available on the Wiki.

The Improved Scala Eclipse Plugin

For the last few days I’ve been working on an Eclipse plug-in using a combination of mixed Java/Scala projects. That is, the same source folder contains both Java and Scala files. I think it’s awesome that this is finally working! At least I wasn’t aware if it was working before. There are still bugs in the Scala Plug-in for Eclipse, but the integration with JDT is now a lot better than before, thanks in part to Equinox Aspects as I understand. You can get the 2.8.x branch of the Scala plug-in, which contains the improvements, from the nightly builds update site.

Also, I noticed a curiosity: I wrote the most complex parts of the mixed projects in Scala, but I mostly created bugs in the comparatively trivial Java code. The Scala code ended up almost bug free from the start, even with hours and hours of coding without actually running the code. Is it really harder to create bugs in Scala? I’d like to think so.

Ziggy Returns, Rewritten in Scala

For about three years already I’ve been working on and off on a server/bot that runs Interactive Fiction games on web forums, effectively turning the single-player text adventure games into cooperative. The beta version launched at Idle Thumbs more than a year ago, but unfortunately it had some problems that made it crash regularly, and I didn’t find the time to fix them.

We’ll, a couple of weeks ago I decided to take the time and rewrote the main server code in Scala. That took only about a week and a half, the bot is now live again and running Hitchhiker’s Guide to the Galaxy. There are still several Java libraries in use of course: Z-Machine from Zinc, Bulletin Board API and ECF, Velocity, HTTPClient etc. But the main server code is now written in Scala.

My main goal for this rewrite, besides switching to Scala, was to simplify the architecture (back to the roots, I guess): the previous architecture was becoming too enterprisey for such a small project. It had too many layers of abstraction, some multi-threading issues made the code hard to debug, and using an OSGi runtime proved to be not that useful in my context. I still think OSGi is great, but sometimes simplicity is even better :)

Thankfully, ECF still works outside of OSGi and only requires two libraries from Equinox. By dropping OSGi, I could simplify the build process (or at least move it to what I’m more comfortable with – Maven). On the server I’m simply launching a Scala object with a main method instead of an OSGi runtime and that is good enough for this project.

The management console application was dropped as well, but I’m exposing some MXBeans on the server so VisualVM or JConsole can be used for management. Web-based management is planned for the future.

Another simplification was dropping some layers of abstraction and removing code that was there only to support hypothetical future features (such as games on IRC and IM, many Interactive Fiction VM implementations etc.). I may be adding some of those layers back in the future, but for now the code should focus on making the core functionality (running a Z-machine game in a vBulletin or phpBB forum thread) as good as it can be.

Perhaps the most improvement that came from this rewrite was that Scala code tends to be about two times shorter than equivalent Java code, as I aslo experienced with my Scala port of Box2D, which I mentioned in a previous post.

But I would say that using Actors for communication between different threads has also gained me some simplicity and I was now better able to understand and fix some of the concurrency issues that used to make the server hang. However, I wasn’t able to move to a completely Actor-based communication model yet, as some of aspects of the messaging between the Z-machine and the forum bot still seemed easier done using other methods, such as blocking queues. Maybe I just don’t know enough about actors yet.

Overall, I’m happy with the result so far and since I find programming in Scala to be more enjoyable than Java, I think I will be more motivated to further develop Ziggy and keep it running smoothly from now on.

Modelling Game Entities Using Traits

For a while now I’ve thought that Scala would be a good language to write games in. Well, I’m putting those thoughts into practice: I resurrected a couple of old game ideas and am now working on a 2D game or two as hobby projects. I decided that it would be a good idea to try my hand on simpler games before I embark on a longer project (which will likely be a platformer), so the one I’m working on now is something of a mix between Breakout and Peggle.

As part of writing those games, I’m also designing a generic game entity system, which will be integrated with Slick2D (for graphics, sound, input and other stuff) and a Scala port of Box2D (for collision detection and physics) that I’m also working on. So far I am very pleased that I chose Scala for this project — the code is generally more concise than Java (requiring roughly 2 times less lines), but what I like most is that traits, pattern matching plus some other features make Scala a great language for building components.

With the entity system I’m trying to take full advantage of that, implementing the building blocks for entities as traits that deal with different concerns. Some of these traits only define an interface for some type of behavior, but some also implement it, reducing the amount of code needed in concrete entities. Here are some of the most basic traits I’ve got implemented so far and descriptions of what they do:

Entity – the base trait for all my game entities, which extends Updateable, making it able to act on updates (or “ticks”) from the game engine during each frame.

PhysicalEntity – can be mixed into an entity class to add a physical body to an Entity, which takes part in the physics simulation and collision detection.

GraphicalEntity – adds a render method, which the entity can implement to render itself.

WithStates – for more complex entities that behave differently depending on their current state. For example a camera in a sneaking game may have states “Off” and “On”. In the Off state, the camera might not do anything, but in the On state it might be listening to some game events to react to seeing the player. To do this, a specific state (which are implemented as internal classes of the Entities) could mix in the Updateable and/or EventListener traits to react to events differently when that state is active. Additionally, defining state transitions can limit how the entity moves from one state to the other and allows to run some code when the state changes.

EventListener – an entity (or one of its states) with this trait will receive notifications of events it is interested in. This can be used in other objects besides entities and states, but only the latter two are automatically registered as listeners in the event queue.

Environment – this is the container for entities, the physics world and the event queue.

This is not all, but these are the most basic building blocks. Here is the code for a simple entity that makes use of some of these:

class Paddle
    extends PhysicalEntity with GraphicalEntity
    with EventListener with GameStateAware[InGame] {

  // we define the physical body for the PhysicalEntity
  val bodyDef = new BodyDef
  bodyDef.pos = (0,-10)
  bodyDef.fixedRotation = true
  bodyDef.allowSleep = false

  // the radius at which the paddle moves around world center
  val radius = 10
  // keeps track of the number of balls shot from the paddle and currently in play.
  var ballsInPlay: Int = 0
  def noBallsInPlay = ballsInPlay == 0

  // we call a convenience method of the EventListener to listen to some specific kinds of events
  listenTo {
    case ce @ ContactResultEventBetween(body1, body2) =>
      val other = 
        if (body1 == body) body2
        else if (body2 == body) body1
        else null
      if (other != null) {
        gameState.scorer.hitPaddle(this, other.userData.asInstanceOf[PlayerBall])

  // we override the function that is called when a PhysicalEntity is inserted into the world
  override def enterWorld(w: World) {
    val shape =, 0.1f)
    shape.density = 0f

  // define the render method to render the paddle (currently just rendering the physical body as a placeholder)
  def render(g: Graphics) = {
    import org.newdawn.slick.Color
    rendering.RenderUtils.renderBody(g, body)

I am already pleased that I was able to separate the different basic concerns using Scala’s traits and making them easily composable as seen above, but I hope that the real benefits should become apparent in a larger game with lots of different entities. Mick West talks about creating game entities as components in his blog post “Evolve Your Hierarchy” – I think he is right and that Scala’s language support for this (especially in the form of traits) is better than in C++ or Java, where you could do something similar with inheritance, interfaces and object composition. Note: I’ve never been a professional game developer or even got to the point of releasing a hobby project to the wider audience so I’m not speaking from reliable personal experience exactly, but I’ve worked with a few entity systems and this just seems right to me.

I will post more about this in the future, hopefully after having released a simple game :) and I’m considering releasing the code for the entity system under an open source license.