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

Started by
3 comments, last by Mushu 19 years, 4 months ago
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?
Advertisement
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.
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.
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. :)
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]!

This topic is closed to new replies.

Advertisement