Sign in to follow this  
Gary the Llama

I have some questions about creating a 2D engine in D3D...

Recommended Posts

I'm currently working on a 2D engine in D3D8. I've got all my Windows and Direct3D initialization crap setup. It opens a window and sets up Direct3D. Yay. Now is the point where I need to figure out the next few steps. I know that I need to create a tile and map class. But what base class should I derive them from? A surface class? I'm using transformed coordinates. I obviously need a class that draws quads, or would I just put that in my surface class? I'm a little confused, a nudge in the right direction would be greatly appreciated. Am I even going in the right direction?

Share this post


Link to post
Share on other sites
Well, first of all, you should stick with what works best for you. Because, its your code and it needs to make sense to you. Now that we got that out of the way..

I structured my 2D engine like so:
  • Quads - the bottom of the tree. Contains the vertex information for one quad, and a reference to a texture. Passed to a quad render function, which... renders the quad.
  • The Map - basically an array of quads. No biggie. There were different layers of the map, a bottom layer, mid, and top. This was so I didn't have to sort through depth stuff.
  • Objects - just another set of quads, with a different conroller. Drew from the top->down so that the overlap looked nice.

Other than that, I don't know what else to tell you as per what you're asking. That's just one way of doing things; its always best to devise your own!

EDIT: and almost forgot - MAKE SURE TO MAP EVERYTHING OUT BEFORE YOU CODE! This is really important at this stage; make sure all your classes support everything you will eventually want to do. Otherwise you'll code yourself into a corner, and that is bad. Real bad.

Share this post


Link to post
Share on other sites
Quote:
Original post by KrazeIke
The ID3DXSprite interface might be useful to you. I think it was around in D3D8, but I'm not entirely sure. It will allow you to draw sprites without having to worry about textured quads.


Got any good links to tutorials that show you how to use ID3DXSprite?

I remember seeing some a while back but I'm retarded and didn't bookmark them. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Gary the Llama
Quote:
Original post by KrazeIke
The ID3DXSprite interface might be useful to you. I think it was around in D3D8, but I'm not entirely sure. It will allow you to draw sprites without having to worry about textured quads.


Got any good links to tutorials that show you how to use ID3DXSprite?

I remember seeing some a while back but I'm retarded and didn't bookmark them. :)

Check the FAQ in the section labelled "2D". Plenty of good links there [grin]!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this