Fish Salad: Become the king of the ocean!
This term a friend of mine, Martin Kinkelin, and I programmed an OpenGL based game for university. The aim of the game is to become the king of the ocean. You start as a little fish and eat other (smaller) fishes. As you eat, you grow and are able to eat bigger fishes. This goes on until you have reached a certain size to be called the “king of the ocean”.
How to play?
Use the arrow keys or A, S, D, W to control the fish. Try to collide with smaller fishes to eat them and try to avoid collisions with bigger fishes. Before starting each level the game tells you what kind of fishes should be avoided in the upcoming level. All other fishes can be eaten!
Special effects
We have implemented pixel and vertex shaders. The caustics are implemented in the pixel shader. They are displayed on each fish and the ocean ground. Side note: To display the shaders you need a decent video card!
The game includes also per-pixel-fog and motion blur. You can see the motion blur, if you collide with a bigger fish. It is shown as long as your fish blinks (in that time you are invincible).
Other points of interest
All models in the game are stored in a custom written format. We have written a converter to translate .obj files to our .fsm format. The model-configuration is found in the Models directory and stored as xml file. That allowed us to easily customize the models behaviour. The levels are also stored in the game.config file, which is found in the same directory as the game’s .exe. Feel free to add your own levels ![]()
We are also using quaternions to rotate stuff in the 3D space. That’s gives us better results and is faster when rotations are concatenated. To make the game even more performant SSE intrinsics are being used
If have had some problems with the game under Vista. That’s due to the buggy nVidia drivers for my mobile GeForce 6800. I haven’t had any problems under Windows XP. The game works well in Vista on my girlfriend’s computer. She has a GeForce 7xxx. Martin has an older Radeon card and Windows XP and it works also great there!
I hope you enjoy the game!
Note: If you get an error while starting the game, try to download and install the latest MSXML package from here.
Published on Jun 25th, 2007 —
Tags: Games, OpenGL, Programming, University
Comments (3)
digg it!
kick it
One-time initialization factory for .NET
I recently read Robert Saccone’s and Alexander Taskov’s “Synchronization Primitives New in Windows Vista” article in the current MSDN Magazine. It’s very interesting that Vista offers new native APIs to allow delayed initialization of singleton objects in C/C++. Now I thought, why not have something similar that is written for .NET?
The result is a class called SingletonFactory
/// Factory that creates a singleton on demand.
/// </summary>
public sealed class SingletonFactory<T>
{
/// <summary>
/// This delegate is used to construct the singleton instance.
/// </summary>
/// <returns>The singleton instance.</returns>
public delegate object CreateSingletonDelegate();
private T _instance;
private bool _created; // Changed type base upon ideas from Sven Groot.
private CreateSingletonDelegate _singleton;
/// <summary>
/// Creates a new instance of the SingletonFactory Class.
/// </summary>
/// <param name="singleton">The delegate instance used to create the instance.</param>
public SingletonFactory(CreateSingletonDelegate singleton)
{
if (singleton == null)
throw
_singleton = singleton;
}
/// <summary>
/// Gets the singleton instance. Constructs it, if not constructed already.
/// </summary>
/// <returns></returns>
public T GetInstance()
{
// Use a double checked lock to avoid concurrency problems.
if (!_created)
{
lock (this)
{
if (!_created)
{
// Create the instance.
_instance = (T)_singleton();
_created = true;
}
}
}
return _instance;
}
}
To use the factory, you need to create a static instance (as static class field), in the class that is that is exposed as singleton. When creating the SingletonFactory instance, you need also to specify a delegate that creates the instance. In the following sample that delegate is implemented as anonymous delegate:
/// Sample class.
/// </summary>
public class Foo
{
// Instance of the factory.
private static SingletonFactory<Foo> _factory =
/// <summary>
/// Returns the singleton instance for this class.
/// </summary>
public static Foo Instance
{
get
{
return _factory.GetInstance();
}
}
}





