PDA

View Full Version : I need help ?in making a game in 2d



eduardo3
03-26-2001, 06:44 AM
I need information to start program a game in 2d( like donkeykong )if anyone know some papers of programming or source , anything.

I want to start a game in 2d because I am study opengl lesson 23 and lesson 10 of nehe and there is in 3d.I wnat to start coding a 2d game first and later in 3d.
My brother is making the bitmaps for the game right know , and I need help width the programming..if you can help me please

Handkor
03-26-2001, 07:24 AM
If you want to make a game in 2D, you will need to use OrthographicProjection. I use the two functions below.

void setOrthographicProjection() {

// switch to projection mode
glMatrixMode(GL_PROJECTION);
// save previous matrix which contains the
//settings for the perspective projection
glPushMatrix();
// reset matrix
glLoadIdentity();
// set a 2D orthographic projection
gluOrtho2D(0, w, 0, h);
// invert the y axis, down is positive
glScalef(1, -1, 1);
// mover the origin from the bottom left corner
// to the upper left corner
glTranslatef(0, -h, 0);
glMatrixMode(GL_MODELVIEW);
}

void resetPerspectiveProjection() {
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
}

Source http://www.fatech.com/tech/opengl/glut/index.php3?1

Anything drawn between the two function calls will be in 2D.

To display images, you can simply create quads in 2D with glVertex2f and add textures to your quads.

See NeHe lesson 20 on how to get rid of the black borders with masking.

eduardo3
03-26-2001, 07:36 AM
THANKS , I will view this and I mail you .