Vthrust

From Lundman Wiki
Jump to: navigation, search

Work launched a G-GAY Games center, and suggested that we should submit something. I just did a clone of the old C64 game Thrust.

This project uses VIVID runtime, by Acrodea. Which is a C and C++ wrapper API for Android (iphone?). OpenGL, OpenSLES/OpenAL and so on. Although, OpenAL did not work correctly so do not use it. You can get the SDK from Vivid.

The SDK is still very young, and quite rough around the edges. For some very peculiar reason, they took a platform (Android), famous for its inter-platform development (Windows, OsX, and Linux!) and made a Windows Only SDK. Wow! But that is pretty much for-the-par with GMO.

So due to that, I run Windows in VirtualBox just for compiling. This meant that the VIVID UI Builder did not work correctly, and I had to set the callbacks from code etc. No matter.

I use Eclipse for compiling. So if you fetch my sources, you most likely want to use Eclipse too. But it should not matter.

Sources are here

gthrust First version sources

The Ground is done with triangle meshes, I use the OsX program called Meshwork. No real reason, except it let me just draw lines, and later fill in triangles. Most 3D modelling programs have methods for creating cubes, and more complex objects, but no free-drawing. That aside, creating a world is quite easy, but tedious.

I use the Bone feature to place objects in the world. Click on the place to create a new Bone, then name it:

Bone name      Description
SHIP           Player Ship placement.
BALL           Pod placement, this should always be on flat ground, so place bone on a horizontal/flat polygon line/ground, and pod is adjusted upwards to rest it correctly.
FUEL           Fuel tank placement, place directly on horizontal/flat line/ground.
PLNT           Power plant, as above, place on ground.
TU00,TU01      Turret/Limpet 0 gun placement. Use TU00 for center positioning, resting on a line. Use TU01 as left-corner, to set the angle of the turret.
TU02,TU03...   Turret 1 placement...

Once you have saved the Meshworks file (which appears to not have an extension?) The ground data is processed into game format, using:

# ./level_load meshwork_file output_file

My thrust clone divides the world into squares, of 1.0 Unit in size. In Meshworks, this is actually 40 Units. It uses simple 2D line intersection to determine if each triangle occupies any space of each grid. In the game, I take each of the ships 3 points, and calculate which grid-block it is inside, to get the list of triangles that are also in the same grid.

To determine if the ship point is inside the triangle, I use Barycentric Technique as found here [1].

The same goes for bullets hitting the ground, bullets inside space ship. To finish off collisions, we also have standard point on circle tests for bullets on the shield and pod.

If you fail to build the sources, delete the contents of script, and __backup__ directories. They seem generated by the UI Builder.

The maps generally should start on Y-Axis = 0, and go down. Around Y-Axis of 3.0 (Meshworks 120) is considered 'leaving the planet'. Likewise, if the ship is in positive y-coordinates, -3.0 and +3.0 is considered as having left the game area. If the ship is underground, you may make levels to go as far left and right as you wish.

If the Plant is hit 4 times with bullets, the count down to core-critical starts. Currently 10 seconds is almost impossible, even for me.

The Thrust image is Copyright NASA.

The Music is from old Amiga module by (c) paso/u.d.o

Other TODO:

No collision between ship and objects, like turret, power plant and fuel.
More maps?
Reverse gravity?
Better controls, like accelerometer would be interesting.