BodyBuilder, which I commented on a previous post, has been updated to work with multiple fixtures, keeping simplicity.

Internally, it uses a FixtureDef builder named FixtureDefBuilder which lets you specify a fixture definition for each fixture.

Here is an example of how it looks now it supports multiple fixture definitions:

Body body = bodyBuilder 
		.fixture(bodyBuilder.fixtureDefBuilder() 
				.circleShape(radius * 0.1f) 
				.categoryBits(CategoryBits.MiniPlanetCategoryBits) 
				.restitution(0f)) 
		.fixture(bodyBuilder.fixtureDefBuilder() 
				.circleShape(radius) 
				.categoryBits(CategoryBits.AllCategoryBits) 
				.sensor()) 
		.position(x, y) 
		.mass(1f) 
		.type(BodyType.StaticBody) 
		.userData(e) 
		.build();

The previous example shows how to declare two fixtures for a Body, one of them is a sensor. For you to know, I am using that code in Super Flying Thing to declare the destination planet (that’s the name for now), the sensor is to detect when the ship is near to trigger an event and then attach it to the planet by creating a Box2D Joint.

If you are a game programmer, it could be useful to maintain your code clean and simple.


We are working on a prototype for a new game with no defined name, graphics and sounds yet. But, game mechanics are, and they are fun, at least for me (arielsan).

In a simple description, the game is about a flying thing (probably a ship) which should travel from one safe point to another through a series of difficult paths.

Super Flying Thing - Screenshot
(note: I wanted to post a video but I had problems recording it)

There are going to be two game objectives, a main objective of reaching the destination alive and a second objective of taking all the stuff (coins, stars, diamonds, box2d polygons, something) on the level.

Game mechanics are not fully decided yet, the idea is to make simple levels and don’t allow you to receive a single hit on the ship, else you die. However, one option is to have some kind of shield and if you reach the destination with full shields then you have a Perfect score.

Also, game controls are a bit too sensible for now, but game levels are not defined so we will improve control sensibility when we have some levels.

We have some ideas in mind like having a level editor and let players share levels and stuff, lets see what happens.

Finally, if you want to try the game, there is a Webstart and also an APK to download, it will be on Android market when we have a name decided, or maybe with Super Flying thing name.

Play on PC

Instructions:

  • LEFT key to rotate ship left
  • RIGHT key to rotate ship right
  • SPACE to release the ship
  • R to reset the level and generate a new one on random and practice modes

or play it on Android:

Play on Android

Instructions:

  • Touch LEFT half of the screen to rotate left
  • Touch RIGHT half of the screen to rotate right
  • Touch screen to release the ship
  • MENU key to reset the level on random and practice modes

That’s all for now, hope you like the game and enjoy playing it.

UPDATE: added the missing screenshot


In almost all of our latest games we are using libGDX as our main game library. As it comes with a wrapper of well known physics library Box2D, we are using it as well.

Some times when creating a Box2D body, you have to initialize a lot of stuff, you have to create a BodyDef and a FixtureDef and then create the Body with the BodyDef, after that create the fixture on the body using the FixtureDef, it could be a bit confuse.

The next code snippet shows an example of that:

BodyDef bodyDef = new BodyDef();
	FixtureDef fixtureDef = new FixtureDef();

	bodyDef.type = BodyType.StaticBody;
	bodyDef.bullet = false;
	// ... more stuff

	Shape shape = new CircleShape();
	shape.setRadius(radius);

	fixtureDef.shape = shape
	fixtureDef.friction = 1f;
	// ... more fixtureDef stuff

	Body body = world.createBody(bodyDef);
	body.createFixture(fixtureDef);

To improve this a bit, I have created a BodyBuilder which lets you build Box2D physics bodies in less code lines.

The following code snippet shows an example of using the BodyBuilder:

Body body = bodyBuilder
			.mass(1000f)
			.circleShape(radius * 0.1f)
			.position(x, y)
			.restitution(0f)
			.type(BodyType.StaticBody)
			.categoryBits(MiniPlanetCategoryBits) 
			.build(); 

As you can see, it looks smaller and cleaner. However, it has the limitation (because I was lazy when I did the class) it works for only one fixture def, if you want to build a complex body that will be a problem.

There is also a similar builder for Joints named JointBuilder but it is just started.

The following code snippet shows an example of using the JointBuilder:

Joint joint = jointBuilder.distanceJoint() 
			.bodyA(bodyA)
			.bodyB(bodyB)
			.collideConnected(false) 
			.length(1.5f) 
			.build();

If you are using libGDX Box2D as well, both classes could be of help despite they are incomplete.


Some time ago we started a web application on github named datastore-server which allows us to store data for our games in a remote server hosted on Google App Engine. Since the first data we needed to store was game scores, and we required more specific queries for them, datastore-server end up being a high scores server, at least for now.

We made an introduction of some of the requirements we wanted for the scores server in a previous post, we made some modifications to the basic concepts.

Profile

First of all, we added a new structure which identifies the player and has the following fields:

Profile {
    privateKey : String - a unique private key owned by the player on the client application, used to submit scores
    publicKey : String - a unique public key used to identify scores
    name : String - the player name
    guest : Boolean - if the profile is guest or not
    }

Score

Score structure has been modified to have a profile reference, and also some extra data required for scores filtering improvement (filter by date range):

Score {
    .... (previous data)
    profilePublicKey : String - a reference to the profile owner of the score 
    year : Integer - the year the score was submitted (calculated in the server)
    month : Integer - the month of the year the score was submitted (calculated in the server)
    week : Integer - the week of the year the score was submitted (calculated in the server)
    day : Integer - the day of the year the score was submitted (calculated in the server)
    }

The server now provides the following features:

  • create guest and non-guest profiles for score submission
  • submit a score for a game given a profile
  • request scores given a criteria

Creating and updating profiles

To create profiles datastore-server provides a query named /newProfile with two parameters:

  • name : String - represents the name of the profile
  • guest : Boolean - if the profile is guest or not

The query returns the profile structure as JSON so that the client can save the private and public keys that are generated on the server.

We also provide a way to change a guest profile name and to make it be non-guest using the /updateProfile query:

  • privateKey : String - identifies the profile
  • name : String - the new name we want for the profile

Submitting a new score

To submit a new score we now need a guest or non-guest profile, it still uses the same query /submit with the same parameters plus the profile privateKey.

Requesting scores

To ask for the scores of a game we have the /scores query with the addition now of two new parameters:

  • distincts : Boolean - if scores should be filtered to return only one score per player (optional, true by default)
  • range : enum { day, week, month, all } - filter best scores by today, this week or this month respectively (optional, all by default)

So, for example, if you want the 50 best scores of the week for a game, you will query /scores?gameKey=something&limit=50&range=week.

Datastore Java client

Finally, to communicate in an easy way with datastore-server we created a Java library named datastore, also on github, which abstracts all communication stuff using apache http-client and also provide classes for score and profile concepts.

If you want to see high scores in action, you could play Face Hunt on PC here or on Android here, also you could take a look at the source code here.

Both projects datastore and datastore-server will probably change in order to incorporate other data storage beside scores.

Hope you like it.


Another Face Hunt update on Android Market, changes this time are:

  • Improved high scores.
  • Changed fonts for high scores and tutorial.
  • Changed background to look a bit nicer.
  • Added wake lock to avoid application to sleep when playing.
  • Modified default name for guest profiles to be guest-xxxxx instead undefinded-xxxxx.

We know it looks like a small change, but the release is related with some updates we made to our high scores system. We will talk about it in future post.

Hope you like it.