On SFT, levels are defined by the following information:
- The position of the starting planet
- The position of the destination planet
- The obstacles, specified by a collection of vertices and if they are dynamic or not
- The items, specified by their position
- For dynamic obstacles, a list of vertices specifying the path they follow
To declare this stuff on Inkscape, we are using three layers: World, Paths and Obstacles.
World layer is used to declare starting positions like start and destination planets and items.
Paths layer is used to define paths to use for dynamic obstacles (and probably for other stuff too).
Obstacles layer is used to define the shapes of the obstacles of the level. If the obstacles are dynamic we could link them with a defined path to make them follow it in the game. To link it we are using, for now, a custom xml field named movementPath with the id of the path we want.
We also have a templates layer, used to define templates for stuff we want to replicate later in other layer, for example, premade obstacles. That layer is not being processed when the level is loaded.
Here is a screenshot of one level being edited:
Using Inkscape as level editor for Super Flying Thing works great, however, we believe it could be an interesting feature to have an in-game easy to use level editor, to let players create their own levels and probably share them with other players.
Hope you like it.
A new version of Super Flying Thing was released, here is a screenshot:
And here a list of changes:
- Improved a bit controls to be less sensible (keeps being a bit hard on Android though).
- Added six simple levels on Challenge mode, created using Inkscape.
- Changed the obstacles to be filled now, as you see on the screenshot, also the planets.
- Added in game basic instructions.
- Added a pause screen where you can restart level or ask to show instructions again
- Added a game over screen shown when you die playing Challenge mode, not 100% sure about how it stops the gameplay
Some stuff for debugging purposes:
- Toggle controls customization window by pressing 0, this window lets you customize ship’s movement values like acceleration, etc.
- Take screenshots by pressing 9 (saved on your tmp folder).
- Toggle FPS by pressing 8
- Toggle Box2D debug renderer by pressing 7
Now, if you want to play it, links again:
We will be trying some new stuff on the next days like moving obstacles and others.
That’s all for now, hope you like the game and enjoy playing it.
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.
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.
- 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:
- 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
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.