Tech Stack!

For the more technically minded amongst you here is the tech I use to create my blockworld.

Language: Java

Because Java is almost as fast as C++ but with none of the manual memory management rubbish. Also Java is great!

Framework: jMonkeyEngine

jMonkeyEngine is a bit like Unity in C++, its a scene graph based 3d graphics library for java that uses OpenGl under the hood (i.e. it runs on the graphics card so its fast!).

[Full disclosure I think its got a lot more in it besides that but that’s what I largely use it for]

jMonkeyEngine is great because you can get started really really quickly, here’s a hello world

public class SimpleBox extends SimpleApplication {

    public static void main(String[] args){
        HelloJME3 app = new HelloJME3();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        Box b = new Box(1, 1, 1); // create cube shape
        Geometry geom = new Geometry("Box", b);  // create cube shape
        Material mat = new Material(assetManager,
          "Common/MatDefs/Misc/Unshaded.j3md");  //use a built in material 
        mat.setColor("Color", ColorRGBA.Red);   //make the material red
        geom.setMaterial(mat);                   //use the material on the cube
        rootNode.attachChild(geom);              //make the cube appear in the world
    }
}

And that creates:

redBox

So; easy!

But jMonkey doesn’t stand in your way when you want to do more advanced stuff.

You may be thinking; hey that looks like a block, is your game made of hundreds of thousands of those? And the answer is: originally yes, until I found out that that is a terrible terrible idea. It works but is really really slow because the graphics card hates all those separate geometries (it asks if you can see each one, each has its own material etc etc). So what do you do? You merge blocks together into chunks. These are great because they are small enough that you can recreate one from scratch in a single “tick” but big enough that they can be drawn efficiently. But we’re getting into architecture now so I’ll leave that for another post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s