Help on getting started on 2D engine

Started by
4 comments, last by avocadoBreeder 21 years, 10 months ago
I''ve been reading all other posts about 2D in this forum and search the net now for almost 24hrs straight but only to find that I _cant_ find the info I need so here goes.. I''ve been programming OpenGL for some time now just to make useless apps and I really wanna get started doing a 2D engine to fiddle around with. But I have no idea where to start, really no idea. All 2D engines I''ve found are tilebased (when one bitmap is looped over and over to produce ground, background, etc..right?). What I''m looking for is more like... the technique used in the old game Another World(Out of this world). Thing is that I can''t even find out what it''s called. And as I said, don''t even know where to start. I got one big background picture which I want to load and the character should run in front of it. And I can''t find any help on collision detection when it doesn''t come to non tilebased stuff. So.. anyone got any ideas..? I''d be very thankful.
Advertisement
IIRC, Another World uses 2D vectors/polys, so this is basically 3D without the Z (depth) axis. Think Flash. Most 3D techniques should apply very well to 2D with minor differences. I hope.

2D now!
Ohh.. so if I exclude the Z depth in regular 3D techniques I should be ok? Very basically that is... hmm(brain starts to work). How would you do a background? First thing I would think of would be to create a flat box as background and place a huge texture on it. This idea seems just silly... Any suggestion?

And thanks alot for the info. Btw..*ahem*..what does IIRC mean?

[edited by - avocadoBreeder on May 30, 2002 4:28:58 PM]
You mean to create a 2d engine that uses open gl for rendering?
How you render the background is up to you. There''s way of manipulating the view and projection matricies in OpenGL to render polygons with a coordinate system equal to your view resolution. glSetOrthoView or something like that.

After you get that down, it''s just a matter of you coming up with a class for your rendering routines, and implementing it. I really can''t direct you on this because I havne''t played the game you mentioned.

___________________________Freeware development:ruinedsoft.com

  glViewport(0, 0, static_cast<GLsizei>(screenWidth), static_cast<GLsizei>(screenHeight));	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluOrtho2D(0, w, 0, h);	glScalef(1, -1, 1);// invert the y axis, down is positive	glTranslatef(0, -h, 0);// mover the origin to the upper left corner	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();  

That will set up a projection where you can use normal pixel coords for placing stuff. Your screen gets mapped kinda like this:
   0  1  2  3  4  5  6  7  8  9 10 11 12 13--------------------------------------------- 0| 1| 2| 3| 4| 5|

I hope that made sense.

Anyway - for the background. OpenGL has a function called glDrawPixels(). This takes a stream of color data and plasters it straight to the screen. No poly texturing or anything. Check it out.


Landsknecht
My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.
Great! Thanks alot for the superb feedback(and code snippet!)! I'm checking out Nehe at the moment and will try to "convert" all his tutorials to a 2D point of view. Please tell me if I'm doomed right now and on the wrong track.

Btw, does anyone have a good plan for setting up a 2d engine? Like how to divide classes into what and such.. a good plan and setup simply.

Thanks again

P.S Here's a link to the game I was referring to: http://www.mobygames.com/game/shots/gameId,564/

[edited by - avocadoBreeder on May 31, 2002 8:05:53 PM]

This topic is closed to new replies.

Advertisement