2D games, Direct Draw??

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 2D games, Direct Draw??

      I was just reading a sample chapter from a game programming book, and came across this:
      When I wrote this chapter I considered writing it using DirectX 9, since it is the API that is the latest and greatest from Microsoft. After about 50ms, I decided to use the DirectX 7 interface with the examples.The DirectX 7 code in this chapter is well tested and shows important concepts that will be useful for any game that needs to manipulate pixel surfaces.


      Which brings me to my question: When making a retro 2D game, what version of DirectX should be used, DX7 or DX9 ??
      Many thanks in advance.
    • RE: 2D games, Direct Draw??

      It really depends on how much time you want to spend on it. The real issue is that, as of DirectX 8, there is no more DirectDraw. You have to do everything in DIrect 3D.

      If you want to use the old-school DirectDraw interfaces, you can probably get something up faster and easier. However, DirectX 9 will allow you to take advantage of the video hardware and give you a few things for free that are hard in 2D, like rotation and scaling. But it's also harder to deal with.

      Personally, I'd say go with DirectX 9.

      -Rez
    • Retro 2D screams Allegro. It uses DirectDraw (ie. DirectX 7) which will get you hardware-accelerated masked drawing and a few other things. The rest, including rotation, scaling, and super-cool blending, is done in software, which shouldn't be a problem if your game is truly "retro" enough to not need these things (too much). But if it does, you might have a problem.

      There is an add-on library that fixes the blending problem for the most part, but the best overall solution is using AllegroGL. It requires a little knowledge of OpenGL to set up and use, but for the most part I believe you can use the same function calls as plain Allegro.

      Either way will work to some degree, it just depends how much you wanna learn. AllegroGL is being merged into Allegro in version 5.0, so I don't even know if it's worth learning Allegro in its current state.

      There's also SDL, which will get you about the same as regular Allegro. But they are evil and don't have an awesome community, like allegro.cc. :P
    • Heh - heck you could even use Flash...
      Mr.Mike
      Author, Programmer, Brewer, Patriot
    • Many thanks for all of your input.

      kibiz0r,
      Call me stupid, or glutton for punishment, but, although i like allegro and have played around with it..i kind of want to do it myself, the hard way, with DirectX or possibly OpenGL and even less likely SDL.

      Rez, i have very little DirectX experience, and would like to learn more about it, i have struggled with the decision of weather to use DX7 or DX9 ever since i thought of making this project, as you say DX9 is more complicated/complex, but has a lot more to offer.
      The other thing that has been bugging me is making it cross platform, i am a windows user, period. Its not that i don't like macs, its just that i can't really think of anything that i could do with a mac that i can't with my pc, other than play the odd mac only game, that and the fact that they are a tad expensive. Since starting Mr.Mike's book, i have been thinking more and more about making my project cross platform (bigger target audience and all), so i don't know weather to use a cross platform API or weather to try and put all platform specific code in one place so it can easily be changed, and use DirectX just to get the project finished, and worry about other platforms later ?!?!
      I have loads of stuff down on paper, its just me, being indecisive, i need to pick a route and go for it. Every time i think I've made up my mind, i question weather I've made the right choice or not..Arghhh!!.

      Mr.Mike,
      Hi, great book, I'm not that far through it yet, around page 300 ish, but i really like it. I like your writing style, the tales from the pixel mines are really great. Its nice to read a book written by someone who has worked on some of the games that I've played & liked, to be honest i think that your book is the only game programming book that i own, that has been written by a programmer of big title/well known games. I think that you should write another book, or two, or a few.
      If any of you could recommend a good book or books on program design/design patterns, it would be much appreciated. And finally, are there any other game programming books that have been written by programmers from the industry, that have worked on well known games ?? or is it just Mr.Mike ?? or is it that i have just not found enough good books ??
      Many thanks.
    • Have you ever made a game before? If not, I honestly wouldn't worry about being cross-platform. You'll end up spending so much time on it that it won't really be worth it. You should concentrate on making the game and getting something out there. In my opinion, that's much more important.

      As for DirectX, I'd say jump in the fire and go for 9. DirectDraw is pretty dead in the industry as far as I know. Even 2D games are using DirectX 9 (although I can only speak for two companies).

      And I completely understand your desire to do it all yourself. I think that's a great idea because you'll be forced to learn all the nitty-gritty under-the-hood stuff. It's crucial to understand all that. Sounds like you're well on your way! Maybe we'll see you at GDC some year and I'll buy you a drink.

      -Rez
    • I have made a couple of 'small' games, and i do mean small, single screen, static background, arcade style alien shooter and a hang man game with really crappy graphics drawn by moi, with a mouse and mspaint, of a cowboy (hat and all) who hangs from a tree with a stupid grin on his face...total pants!
      So, basically, this project that I'm working on at the moment is my first 'proper' game, an old skool isometric rpg/adventure, i have some literature on isometric engines (ie: Ernest Pazera's Isometric Game Programming, and various articles on GameDev) its all pretty dated, and I'm sure there must be better ways of doing some of the things shown in the literature i have, sadly there doesn't seem to have been anything written on isometric techniques in the last five years or so (not that I've found anyway). I would rather use an old fashioned Isometric tile technique instead of D3D and quads and vertices's to create the landscape, but if there are better/more modern ways of mouse mapping, anchor points and any other bits and pieces then I'm all ears.
      And I completely understand your desire to do it all yourself. I think that's a great idea because you'll be forced to learn all the nitty-gritty under-the-hood stuff. It's crucial to understand all that. Sounds like you're well on your way! Maybe we'll see you at GDC some year and I'll buy you a drink.

      Most people would call me mad for wanting to do things that can be avoided nowadays, but i to believe that history can teach us a lot, and its important to learn the old 'under the hood' techniques. As for GDC...well, you never know, give it a few years and a lot of work, and maybe :) yep, that would be cool...you get the coffee and I'll get the biscuits.
    • Call me stupid, or glutton for punishment, but, although i like allegro and have played around with it..i kind of want to do it myself, the hard way, with DirectX or possibly OpenGL and even less likely SDL.


      [IMG:http://www.lolwut.com/layout/lolwut.jpg]

      You're not gonna get much lower-level than Allegro. In fact, the name stands for "Allegro Low LEvel Game ROutines".

      A lot of the calls are straight assembly, for Pete's sake. Really, what you've got is a software layer on top of whatever hardware API is available on the platform. On Windows, that's DirectDraw. On the other systems, it's something else. It is, after all, cross-platform, which I understand is important to you.

      But if you really wanna use "what the big boys use" and want cross-platform capability, go with OpenGL. OpenGL is just graphics, though, and Allegro can handle the rest (input, sound, timing) quite nicely.

      Anyways, I get the DIY attitude. We're all like that. If we weren't curious and dumb/masochistic enough to try it ourselves, we wouldn't even be having this conversation. But for indie stuff, you gotta use all the torque you can muster to get your ideas on the screen.

      Now, a few inspirational quotes:

      If you have to axe-murder someone to get your game done, then do it. Nobody cares how you got there, even if it is incredibly messy.

      Premature optimization is the root of all evil.

      Don't let the perfect be the enemy of the good.
    • If you're going low-level anyway, I would suggest something like Open GL or DirectX over Allegro. I think Allegro is great for taking care of all the stuff many people don't want to do but if the goal is to do it all yourself, use something common with the rest of the industry so you can get more future use of those skills. We use Gamebryo here, but my knowledge of Direct3D comes in handy when I need to step into the rendering code.

      When I was teaching myself data structures, I rewrote most of the common STL container classes and sorting/searching algorithms from scratch. I even used them in a few programs. Once I had them pretty solid, I shifted my focus onto the STL and never used them again. Going through all that allowed me to understand what's really happening under the covers of a map, vector, set, list, or anything else I dealt with. My advice is to do the same, but with D3D (or open GL). Once you have a game or two written with completely home-grown code, switch to something else like Allegro, SDL, or even one of the 3D engines out there (like Ogre) if you want.

      That's just my opinion, of course. :)

      -Rez