Monday, December 26, 2011

First Implementation

For this first implementation loop I started with the map setup and control of the ship. I'm using temporary assets here for the sake of quick iteration. The ship comes from a FreshEngine PSP sample I did a while back.

Levels

I'm testing first on a city setting, simply because it is modular by nature and will help me defining the game constraints. I choose to use a 1 unit for a bloc of the city. So I can quickly and easily build large cities. I built 2 buildings blocs and one ground bloc in Maya and then exported them as static objects.



In Tiled, I created a test map using small 64x64 pixels icons for each of the tile. I export the map in the CSV format (Coma Separated Values).

I then wrote a small xml parser in lua to extract the values and generate the map in a lua table with each tile index.

At load time, I load the CSV file (a few kilobytes), generate the table and simply instanciate my static objects depending on the index in the table, and voila the map is generated in a few miliseconds.

Control

My first implementation of the ship control was in Lua so I could validate the functionnality. Now it's all in C++ and is much faster.

I'm using constraints to drive the ship so I can introduce some delay by simply changing the strength of the constraints on each axis. The camera is also constraint to the ship (using aim and position constraints).

Controling an object in camera space requires to take care of a few things.

In order to control the ship at even speed whatever the camera view, I need first to project the camera front vector onto the XZ plane otherwise the speed of the ship would vary depending on the camera pitch.

As my camera will not roll, I can take the camera Right vector as is.

Then I can modulate the stick vector by these projected camera vectors.

Next I need to check for the length of the vector not being greater than 1. It can happen when the stick is in diagonal because the diagonal is longer than each separate stick axis. If that's the case, I need to limit the length to 1.

To switch altitude, I simply change the altitude of the position constraint of the ship and the engine smoothly interpolates (weights inependently set on each axis) the ship position.

Here are some screenshot from the PSP version:
This is when flying at the upper altitude (1 unit). So the ship can fly above the buildings.


And now, when pressing the altitude switch button, it goes to the lowest level (.3 units):


Notice how the camera is now almost vertical to allow a better readout of the situation and enable the player to easily fly around the buildings.

I also change the camera field of view (FOV) so the view gets almost orthogonal when the ship is at the lowest altitude. This completely change the perception of the game and makes you fell more involved in this view. It will be useful when interacting with ground objects.

The shadow really helps to read the flying altitude. I don't have the shadow yet on the PC and PS3 versions since I need to write some Cg shaders first. On PSP the shadows is managed by the engine and doesn't require writing shaders since it's all fixed pipeline. I'll do that later.

Next post, shooting, collisions and bonuses.

No comments:

Post a Comment