Hi

I’m going to go through the basics of building an easy game design. This game design can be used as an underlying for both 2d and 3d.

First a little background, I’m educated in 2004-08 with programming as a major, and game design and programming as specialty. I have both java and C# both for web and application as programming languages to work with.

Along with just programming I have been going through all from design to distribution, so this hopefully turns out to be thorough.

Now to the basic

As a basic thing we need a class who represent an object in floating space. The object should be able to represent any static item in any floating space. As we are building up to a possible 3d application but not sure yet we make support for it but don’t really use it yet.

So an item in a floating space got a location, this location is considered to be a whole number, so integer fills that purpose. So we got:

Integer x = 0;
Integer y = 0;
Integer z = 0;

We also need to know how big the item is, so adding width, height and length to the item:

Integer width = 1;
Integer height = 1;
Integer length = 1;

Notice that the length, height and width are the value of 1, as no length can be 0 or less, so length, width and height should be |x| and x > 0.

Now that we got an object, we need to know in what direction that it is pointing. If it we assume that it can only point in a horizontal direction, so in this case no up and down direction. Adding this to the API later is somewhat easy if needed, and right now we develop for a 2d game with 3d potential.

The direction is measured in degrees, and degrees can have decimals, so we use a double for this. So we add the last variable to the code:

double deg1 = 0;
double deg2 = 0;

So now we got an item the size of 1^3 pixel in the exact center of the “universe” pointing north.

Now you should have a piece of code looking like this:

package motes;
public class Thing {
           private Integer x;
           private Integer y;
           private Integer z;
           private Integer height;
           private Integer width;
           private Integer length;
           private double deg1;
           private double deg2;
}

Now add getters and setters, if you are using an ide like netbeans or eclipse, they do it for you, if not, you need a bit of effort to get it written, a getter and setter should look like the following:

           public int getX() {return x;}
           public void setX(int x) {this.x = x;}

Just add a constructor to the code and everything should look fine.

The constructor should look like this:

           public Thing(int x, int y, int z, int height, int width, int length, double deg1, double deg2){
                      this.x = x;
                      this.y = y;
                      this.z = z;
                      this.height = height;
                      this.width = width;
                      this.length = length;
                      this.deg1 = deg1;
                      this.deg2 = deg2;
           }

If your programming language supports overloads you can with great advantage add this constructor also.

           public Thing(int x, int y, int width, int length, double deg){
                      this.x = x;
                      this.y = y;
                      this.z = 0;
                      this.height = 1;
                      this.width = width;
                      this.length = length;
                      this.deg1 = deg1;
                      this.deg2 = 90;
           }

Notice how we removed the items we don’t need to make a 2d program but kept them for later use, so we fast and easy can add the values if needed.

Your class should now look something like this:

Mote Warrior UML

That should conclude the first part of the API, you can download the class file from the link below.

 Thing

Stepping it up a notch: Part 2 -->