CheatCat's picture

Rayman 2 2D

Table of contest:

The beginning
Drawing images
Player movement

------
The beginning

The background to this project is this YouTube video:
http://www.youtube.com/watch?v=LW-fpwjT9I0&feature=PlayList&p=A047FCF1E8...
I want to do a fan-game to this game because it was canceled before the game was done!

First I have to decide what I should do the game with..
CsGL http://csgl.sourceforge.net : The page hasn't be updated since 2003. I want something newer.
Allegro http://www.talula.demon.co.uk/allegro : Hard to install and you cannot use it for C#. There is wrappers, but they are old.
AgateLib http://www.agatelib.org : It's slow, I want something faster!
SDL.NET http://cs-sdl.sourceforge.net : The forum is dead, I can look in the sky for help..
OpenTK http... Wait, it is this page! xD : It seems to be a great wrapper, let us try! :D

------
Drawing images

First I run the QuickStart example and get a stupid MS-DOS window in front of the program and I ask for help: http://www.opentk.com/node/890

Now I try to make a simple game!
The first program I use was GameMaker. I just need to load a sprite/image, make a object for the sprite, put the object i a room and hit the play button. Then I have a cute window with the image. Simple.

I want do something harder so I switch to C++ with The Game Creators DarkGDK library (using DirectX). To draw a image to the screen I only need write this code:

#include "DarkGDK.h"
 
void DarkGDK()
{
  dbSyncOn();
  dbLoadImage("img.png", 1);
  dbSprite(1, 10, 20, 1);
 
  while(LoopGDK())
  {
     dbSync();
  }
}

And I have a image at the position 10x20 in a window.
I also try XNA and it was little harder to draw a image but it was something similar as DarkGDK. Of course I have tried other programs and libraries and you draw images with them calling simple functions.

Okey, back to OpenGL and OpenTK. To draw a image you first need to load the image. It's hard and I don't understand what the loading function do in the NeHe Examples (google it). However it load a image and it's all I need to know. I get help at http://www.opentk.com/node/899 and learned that I can use Objarni's TexUtil class to load images.

Now I try to draw the image and to do that you must put it on a sort of plain. You can read more at http://www.opentk.com/node/909 and http://www.opentk.com/node/919

At last I want to put a transparent image in front of another image. But the transparent image get a blue border and cut of the red rectangle! I search for help again.

Well, it is not a very big problem. Moving on..

------
Player movement

Okey, let's move a image! I want add some keyboard functions that check what key the user press down. It's time for search!

Get it, Keyboard[] checks the keys! I add a wall sprite and try to check collision between it and the player. A collision function would be great and it can be inverted by myself if I don't find a pre-done function.
I do the collision function by myself since I cannot find any other. Now I should make the player to fall down if there are walls under the player. Done! (I am almost done! xD) The game go very fast, I must find a way to change the framerate or maybe move the sprite with smaller steps.

It's time to make the sprite jump when pressing Ctrl. Then I can make a level!

I get collision error now: When the player collide with a wall it cannot move! I should try to fix this...


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

It works!

CheatCat's picture

Amazing! xD Do I have to post a new page every time I do something new? Then the blogpage would be spammed..

the Fiddler's picture

You don't *have* to do that, but for new stuff a new page is generally better. For smaller updates, you can simply edit your post and add a comment below (to bump its position in the "recent activity" list).

CheatCat's picture

Okey! :D

objarni's picture

Looks like a fun game! Good luck!

CheatCat's picture

It will be hard to do that game! XD

objarni's picture

Begin small, try building an editor for a level, with parallax effects. That will be a good start to get used to data structures and user interaction. And you will avoid the most tricky parts in my opinion: physics/smooth controls/collision detection/game logic. Baby steps and having fun is the way to achieve something...

triton's picture

Good luck dude, at least you aren't giving up at your first difficulty.

You need to activate blending for transparencies to work. And make sure your images have an alpha channel.

Entropy's picture

It's also important to make sure you've disabled Depth Testing for Blending to have any effect. I lost a few evenings' worth of time tearing my hair out over that one (I was pretty stubborn and refused to ask for help :-p).

objarni's picture

Also remember that whenever you disable the depth buffer logic, you will need to start sorting things to render in the correct order (far objects first, near objects later)