Cubicforest: using Tiled

In a second post I was writting about creating my own level editor. A lot has happended since then (thank You reality, You’re a perfect teacher): games is being written in Java using http://libgdx.badlogicgames.com/ right now and for editing levels I’m using Tiled editor http://www.mapeditor.org/.

I’m very happy from that solution. Level is exported to Json.

Loading done with gson https://sites.google.com/site/gson/gson-user-guide. Just a few classes reflecting Json’s file structure and I was ready to go…

public class TiledMap {

	private Integer width;
	private Integer height;
	private Integer tileheight;
	private Integer tilewidth;
	private List<TiledLayer> layers;
...
public class TiledLayer {

	private String name;	
	private Integer height;
	List<TiledObject> objects;
...
public class TiledObject {

	private Integer gid;
	private String name;
	private String type;
	private Integer x;
	private Integer y;

What’s interesting: loading is done with one line!

public class MapsLoader {

	TiledMap tiledMap;
...
tiledMap = new Gson().fromJson(mapFileString, TiledMap.class);

… and TiledMap class is filled with a data about designed level

Project’s repository: https://github.com/adamskopl/cubicforest-java.

Tiled editor:

tiled.png

Level loaded in a game:

tiled-cubic.png

Cubicforest: built-in editor

I had a lot of thinking about editing levels. Wanting to keep them simple, I’ve chosen good old square tiles solution. First I was convinced, that I’ll save a lot of work by choosing ready editor (like this one: http://www.mapeditor.org/), but after doing some calculations, I’ve decided to make my own.

Continue reading “Cubicforest: built-in editor”

Main reasons:

  • Most part of editor’s code will be used in game play code: functionality of those two is very similar.
  • Switching between game play and editor will be nice (smooth levels testing).
  • It seems that time spent on adjusting design solutions to someone’s editor is similar to time spent on building my own (especially, that game levels will not be sophisticated). Well, reality will verify that.

Time to dive into stream of concrete design thoughts about first version of game editor.

Building a level

Cubic Objects

Every object occuring in a game’s world, will be composed from little cubes called AtomicCubes. Format of models representing those objects will be discussed another time.

Composing terrain.

For now I’m assuming, that terrain will be built from Fields composing a grid. Grid’s role will be only limited to alignment.

Building terrain will consist of filling grid with objects, having gridSurface defined. GridSurface indicates how object should be aligned to chosen grid’s field.

Fields (tiles).

An object with a stand surface defined. The stand surface is the surface, defining it’s occupant 3d location. E.g. if tile has a shape of a cube, it’s stand surface will be defined by cube’s top face. The stand surface has it’s default point, needed to indicate the optimal position for it’s occupant. E.g the position to which occupant is heading, when given an order to occupy given tile.

2013-10-13-2.png

The field has connections to other fields, defining for the occupant the options to change location from tile A to tile B. It does not mean, that tiles have to be adjacent. Types of connections:

  • Path. Object is moving from A to B in a straight line in given time (defined by object’s speed)
  • Teleport. Object is changing it’s location from A to B immediately.
  • Flight. Object is moving from A to B in a curved line, in given time. Example: jump

Inserting objects on the terrain.

Inserting objects on terrain will consist of associating HoldingObject (Field) with StandingObject (e.g Hero).

Gui

Irrlicht has a GUI support and whatever its level is, it should be enough for this game editor. I don’t care how Irrlicht gui widgets look like (well, they don’t look encouraging): it’s an editor, it should be functional, not lovely (sfx: the sound of fist hitting the table)! For now I only need:

  • Choosing objects to put on the level. E.g the lists of objects.
  • Editing attributes of level’s objects.
  • Saving/loading level files. First version of levels will be in JSON format.

Conclusions: pseudo-UML class diagram

Basing on above description, I was able do come up with first version of classes to program. Of course reality will verify that, but work should begin with a plan.

2013-10-13-1.png

Cubicforest

Lately I’ve started work on a hobby project with code name Cubicforest. It’s a 3d game project, which basic assumption is: “everything is from cubes”.

Continue reading “Cubicforest”

It will be a real time logic game, where player is achieving goals by collecting cubes and generating items, which help him to get rid of enemies and escape to the next level. No further explanations needed: the idea will take its shape with design notes and progress reports.