We are back with another Experimental Gameplay Project-entry.
The theme for May was "High Velocity" and our game is called Lightspeed.
Fly through hoops to gain points and speed. You get 20 seconds.
Black and white hoops accelerate you and gives you points. The faster you go, the more points you get.
If you fly through a blue hoop you get an extra second.
You build combo points by flying through several black or white rings in succession. If you have combo points you can Boost for additional speed.
When the time runs out you enter your name, and your score is posted to our online leaderboards.
We couldn't fit learning OpenAL into our schedule so the game is painfully silent. Maybe if you ask us nicely we'll crank something out ;)Controls:
Steer with mouse.
Boost with left-mouse-button.
If the game is running slowly, use C to turn off clouds or reduce your desktop resolution.Prerequisites:Windows:
.net Framework 2.0.OSX and Linux:
Download and install the latest version of mono from: http://www.mono-project.com/.
To run on Windows:
Lightspeed-OSX.command. (Or just run mono Lightspeed.exe in a console)Tech
I (Hannes) recently bought a macbook, and since I don't really want to run windows on it we decided to try some cross-platform development. We settled on C# + OpenTK. Through the seemingly miraculous power of Mono the same binaries seems to work on both Windows, OSX and Linux.
I code in MonoDevelop on the mac and Alfred code using Visual C# Express. MonoDevelop can use the vs-solution files natively so no problems there really. We have our own subversion server to help with the collaboration.
This is a very simple game, but I am very impressed with Mono and OpenTK!
There have been only a few problems with the cross-platform setup.
1) Loading transparent png's work differently on the different platforms. On Mono we have to convert from premultiplied-alpha manually. If you see black halos around your transparent images when running your games on Mono. Try doing this to the textures on load:
int id = GL.GenTexture();
Bitmap bmp = new Bitmap(filename);
BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
// Fix premultiplied Alpha in mono
int p = (int) Environment.OSVersion.Platform;
if ((p == 4) || (p == 6) || (p == 128))
for(int y=0; y<bmp_data.Height; y++)
byte* row=(byte *)bmp_data.Scan0+(y*bmp_data.Stride);
for(int x=0; x<bmp_data.Width; x++)
float a = (float)(row[x*PixelSize+3])/255.0f;
float r = (float)(row[x*PixelSize+2])/255.0f;
float g = (float)(row[x*PixelSize+1])/255.0f;
float b = (float)(row[x*PixelSize+0])/255.0f;
r = r/a;
g = g/a;
b = b/a;
row[x*PixelSize+2] = (byte)(r*255.0f);
row[x*PixelSize+1] = (byte)(g*255.0f);
row[x*PixelSize+0] = (byte)(b*255.0f);
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0,
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
2) Setting mouse position on mono (osx atleast). To be able to use delta mouse movement to steer we wanted to center the mousepointer between every frame. It seems that Cursor.Position = new Point2(..) locks the mouse position for a couple of hundred milliseconds. This makes the center-on-every-frame-technique unusable. We don't have a good solution to this atm. We had to settle for just checking the delta of the mouseposition each frame, which works but only until you hit the screen edge. You can press Space to recenter the mouse if things go bad. For this game you go pretty much straight ahead, so it's not that big of a problem.
Anyway, we hope you enjoy our little game!
/Hannes and Alfred