Sign in to follow this  
Unknone

2D Game Programming

Recommended Posts

I just can't find any books on this subject for a beginner! I would prefer not to use Direct3D, but I will if I have to. Does anyone know any really good and simple ones for beginners that are either free to view on the internet or in books?

Share this post


Link to post
Share on other sites
There's Beginning Game Programming by John S. Harbour. It uses Direct3D, but that's one of the only good ones I've found so far. You might also want to check out Sams Teach Yourself Game Programming in 24 hours, which uses the Win32 API.

I've heard that NeHe's OpenGL tutorials are pretty good (nehe.gamedev.net), but I don't know if they cover 2D or 3D.

Share this post


Link to post
Share on other sites
I think there aren't that many - if any - good and up to date books on the subject, but there are some good tutorials. You didn't mention the language you use. If it is for c++ and you would care to use the SDL api, then lazy foo has a bunch of clear tutorials for beginners, and aaron cox tutorials has some 2d game tutorials too.

SDL is a cross-platform multi-media api, it is quite easy to get things going quickly in 2D and it is rather complete if you use some add-on libs such as SDL_image, SDL_mixer and SDL_ttf. Furthermore, when you need more power you can still continue to use it with opengl, since SDL provides an easy way to setup opengl, transition will be smooth.

EDIT: i found another tutorial site, it uses directx but the concepts are still the same, don't know how good it is though: 2d gametutorial
While I'm still editing I may add that it would be a good idea to check out different options. The Python language with pygame may get you started faster for example, I'm learning it now and wish I did that sooner. You could also consider using an existing engine, I hear good things about Haaf's game engine, which is now free and open source.

Share this post


Link to post
Share on other sites
OK thnx.

Next time someone mentions Sams Teach Yourself Game Programming in 24 hours, I cannot be responsible for the actions that follow. I have heard so many people say it's good, but it is rubbish. It dosen't actually explain the code well enough for my taste. But thnx for the effort :)

BTW, it's C++

EDIT: I've had a brief look at SDL, and I don't really like it. I might have a better look later but ATM I'd really prefer not to. Thnx anyways :) And no, I won't use an engine. That is leaching someone elses work and is not a habit to get into while your still learning. I will probably learn some engines later, but not yet.

Share this post


Link to post
Share on other sites
Have you tried Allegro? I found Allegro easier to use than SDL but that may be because I tried SDL first and I was more of a newb then. Allegro was more of a pain to set up but it has really good documentation and there are some good tutorials out there. I seem to recall someone mentioning a book about using it as well. It might be worth a look. Good luck to you.

Share this post


Link to post
Share on other sites
I am currently working on a tutorial for 2d game programming.
We use it as extra material for a beginners course in gameprogramming at a university.
You need to know resonable good C++ to understand it.

It's not finnished, but the chapters 2-5 is out, 6-7 commin this week.
Currently located at my site...
http://www.necro3d.org/2dgp/

Click on chapter 2...5, then click on pdf or source symbol to get the stuff.

/martin

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Unknone
OK thnx.

Next time someone mentions Sams Teach Yourself Game Programming in 24 hours, I cannot be responsible for the actions that follow. I have heard so many people say it's good, but it is rubbish. It dosen't actually explain the code well enough for my taste. But thnx for the effort :)

BTW, it's C++

EDIT: I've had a brief look at SDL, and I don't really like it. I might have a better look later but ATM I'd really prefer not to. Thnx anyways :) And no, I won't use an engine. That is leaching someone elses work and is not a habit to get into while your still learning. I will probably learn some engines later, but not yet.


IT IS GOOD. Your just not understanding it enough ;-)

Another book to look at though is Beginning Game Programming All In One, Second Edition
By Jonathan Harbour. It goes through using Allegro and puts mostly all of the gamecode in the book itself too and goes through many games. Plus Allegro is much simplier to use then GDI imo.
Sams TYGP24H is a good book to start out with Object Oriented Game design though imo.

Share this post


Link to post
Share on other sites
I'm not using OOP. I'm not using SDL or Allegro. I want to learn the proper way with the actual Win32 API. The 3rd party stuff is not a good habit to get into while your still learning.

And that Sams book is rubbish as far as I'm concerned. I didn't have the CD so I had to download the code. I might have another look at it, I might've missed something. But don't get your hopes up too high...

Share this post


Link to post
Share on other sites
Quote:
Original post by Unknone
I'm not using OOP. I'm not using SDL or Allegro. I want to learn the proper way with the actual Win32 API. The 3rd party stuff is not a good habit to get into while your still learning.


SDL is not very object oriented. Why are 3rd party libraries not a good habit? And why is the 'actual' Win32 API the proper way?

Share this post


Link to post
Share on other sites
I see nothing wrong with using a pre-made library such as SDL. When you were first learning C++, did they make you write and compile all of the STL from scratch? I doubt it. Even in my university courses on the subject, we were simply taught about using STL classes such as string and cin/cout, without any real knowledge of how they worked, or even what classes really were!

In programming, and in computer science in general, you can't start from the lowest level. You will get so bogged down in details and none of it will seem relavent. We start from the top, where you can just pull from a box of tools to get what you want done. This teaches you the basics of programming logic and methods. As you learn, you dive deeper and deeper into the fundemental nature of programming and your lanuage of choice. You don't need to be writing your own 2D/3D library right off the bat because, frankly, you have no business doing it until you become very good at programming in general.

Share this post


Link to post
Share on other sites
Quote:
Original post by Unknone
I'm not using OOP. I'm not using SDL or Allegro. I want to learn the proper way with the actual Win32 API. The 3rd party stuff is not a good habit to get into while your still learning.


SDL and Allegro are not OOP at all. What makes the Win32 API so special? You have to accept some level of abstraction or you will be coding in binary without an OS. Saying that using Win32's abstractions is "proper" but SDL is the easy way out is just ignorant.

Quote:
Original post by Unknone
And that Sams book is rubbish as far as I'm concerned. I didn't have the CD so I had to download the code. I might have another look at it, I might've missed something. But don't get your hopes up too high...


So your version of the book did not have the CD so the book is rubbish?

Share this post


Link to post
Share on other sites
Dude, just use Direct3D. The D3DXSprite interface makes it ultra simple to render sprites. If you feel limited by it(which you probably won't, seeing how feature packed it is) you can then write your own textured quad engine. Have a look at the documentation in the SDK and your good to go. It really is that simple.

Share this post


Link to post
Share on other sites
"Tricks of the Windows Game Programming Gurus", by Andre Lamothe.

It's a wonderful resource for beginning 2D game programming.

You need to know C or C++ to understand it.

It uses DirectX 7, which is then easy to update to Direct3D's ID3DXSprite interface if you wish.

Share this post


Link to post
Share on other sites
1: I'm not saying the book is rubbish 'cus I didn't have a CD. I didn't like the explaination of some things. I might go through it again to make sure I didn't miss anything. And BTW, I got all the stuff from the CD. I had to download it LEGALLY (no, I don't deal with pirated stuff) so I could use the book.

2: Yes, it is a bad habit to get into when your learning. Those 3rd party things aren't gonna help you if you don't have them. That's why I wanted the API.

3: I wouldn't mind using Direct3D. I just don't know how. I need some lessons or something for it. Plus, I need a newer video card to run 9.0 anyway 'cus Micrsoft are morons who are only there to make rubbish stuff and make sure that all the video card companies and stuff like that get paid so that they ignore the rubbish Microsoft put out. THAT's why every version of DirectX needs a new video card.

Share this post


Link to post
Share on other sites
Quote:
Original post by Unknone
2: Yes, it is a bad habit to get into when your learning. Those 3rd party things aren't gonna help you if you don't have them. That's why I wanted the API.


And right after that you state:

Quote:
3: I wouldn't mind using Direct3D.


Hypocrisy. In order for the customer to use Direct3D, he or she much have DirectX installed. In order for you to program with Direct3D, you must have the proper tools installed.

In order to use SDL, you have to have the library (which can be gotten for free and takes all of 5 minutes to download if you have a slow connection). After that, all you have to do is package the .dll file(s) and they're good to go.

Not only that, you actually limit yourself further with DirectX. DirectX cannot be used for Linux, etc, while SDL is platform independant.

There is nothing wrong with DirectX, but to say that using a lib like SDL is bad, then to turn around and say that DirectX is ok is bull.

Share this post


Link to post
Share on other sites
Why does everyone refer to Microsoft as a whole, as if it's one person?

@Andorien: Most people consider Direct3D and OpenGL the "main" graphic libraries, they aren't considered 3rd-party libraries to most people. Gamedev thinks so too with OpenGL forums, DirectX, and alternative libraries forums.

I wouldn't say SDL is bad, I'm not one to say any graphic library is bad for that matter, but DirectX can't be that much worse, seeing how almost everysingle commercial game is done in DirectX these days. Even call of duty 2, which previously(as in call of duty) used OpenGL, switched to DirectX, so they must be doing something right. I am all for OpenGL too, I'm not a big DirectX fan, just my opinion.

Share this post


Link to post
Share on other sites
I think that it doesn't really matter what you start out with. You just need to get coding something. For me SDL was the best option to learn because I could just download Dev-Cpp and all of the SDL libraries and get something going. There are so many SDL tutorials and the documentation is easy to understand. You can worry about which API/library you will use all you want but it wont help you get better at programming. Try SDL. If you don't like it it cost you nothing anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by cherryhouse
Why does everyone refer to Microsoft as a whole, as if it's one person?

@Andorien: Most people consider Direct3D and OpenGL the "main" graphic libraries, they aren't considered 3rd-party libraries to most people. Gamedev thinks so too with OpenGL forums, DirectX, and alternative libraries forums.

I wouldn't say SDL is bad, I'm not one to say any graphic library is bad for that matter, but DirectX can't be that much worse, seeing how almost everysingle commercial game is done in DirectX these days. Even call of duty 2, which previously(as in call of duty) used OpenGL, switched to DirectX, so they must be doing something right. I am all for OpenGL too, I'm not a big DirectX fan, just my opinion.


This is very true. However, I maintain that making a blanket statement that using anything other than DirectX/OpenGL is wrong is rather short sighted, even if you do end up migrating to them. It's like saying that learning from a teacher or a book is wrong because you wont always have them around, even though they provide important lessons that you'll remember.

Share this post


Link to post
Share on other sites
Quote:
Original post by Simian Man
SDL and Allegro are not OOP at all.


I disagree. Although they don't use classes and advanced OOP techniques, they do have some elements of OOP. For example SDL_Rect, SDL_Surface, and allegro BITMAP structures represent a measure of OOP, as they encapsulate state of an "object" and have "methods" that operate on them, even though the methods are really functions which aren't part of a class.

Share this post


Link to post
Share on other sites
Wow....I don't know what to say to this really.

He turned down SDL AND Allegro? Quick question though, why you turn them down? Because they are 3rd party libraries? To me, that is nothing. I started out with SDL, and I am really glad I did. I got the basics of Game Programming in, without having to worry about LOTS of tedious stuff in the Win32 API. I personally don't like the Win32 API that much, but that is just me. Now that I am done with SDL really, I am moving my way into DirectX. To me, since you want to learn 2D GAme Programming it dosen't matter the API you choose but you need to choose one. Because, when you are new, you want to learn the concept of it. Not dive straight in, on how everything works. Learn the concept of 2D Game Programming, and make it easy on yourself. Learn SDL or Allegro, then after you feel you are good enough progress more knowledge on C++ and then try to go with OpenGL or DirectX. That is just my 2 cents though.


Chad.

Share this post


Link to post
Share on other sites
Don't get me wrong, SDL and Allegro look great. But I don't want to get into the habit of using another 3rd party library or engine because then you can't program properly without them. That's why I don't use graphics engines and anyway, I've already looked at OpenGL. But I need to go to the Win32 API to learn certain things, such as how to load up a bitmap WITHOUT any engines or anything. I will still probably learn SDL and Allegro, but that will be after I have a reasonable to good knowledge of the API. Thnx for the help though.

BTW, I never said DirectX is ok. I just said that I wouldn't mind using if I had too. But I probably won't yet, because DirectX is one of the biggest load of rubbish that has probably ever been released by Microsoft. Not because of the programming, but every version needs an upgrade on your computer. And that's a fact so don't try and say it isn't. Some of us don't have the cash, etc. to do that. On a whole for programming, DirectX is good from what I've seen in programming terms.

I don't think of Microsoft as a whole. Some of their stuff and people are actually good. It's just that most is bad, so it's easier to state as a whole that they are bad.

Thnx once again for all help. I appreciate.

Share this post


Link to post
Share on other sites
Quote:
Original post by Unknone
Don't get me wrong, SDL and Allegro look great. But I don't want to get into the habit of using another 3rd party library or engine because then you can't program properly without them. That's why I don't use graphics engines and anyway, I've already looked at OpenGL. But I need to go to the Win32 API to learn certain things, such as how to load up a bitmap WITHOUT any engines or anything. I will still probably learn SDL and Allegro, but that will be after I have a reasonable to good knowledge of the API. Thnx for the help though.


I have to say you have some screwy definitions for the terms 'API' and 'Engine'.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Unknone
Don't get me wrong, SDL and Allegro look great. But I don't want to get into the habit of using another 3rd party library or engine because then you can't program properly without them. That's why I don't use graphics engines and anyway, I've already looked at OpenGL. But I need to go to the Win32 API to learn certain things, such as how to load up a bitmap WITHOUT any engines or anything. I will still probably learn SDL and Allegro, but that will be after I have a reasonable to good knowledge of the API. Thnx for the help though.



No you don't just use Allegro man. Has a very simple bitmap loading code, everything in Allegro is super simple. Works very well infact.

Most game programmers don't focus on writing the engine, instead they focus on writing the GAME.

Plus the Sams book teaches you had to do eevrything with GDI. GDI, ALLEGRO, SDL, All the same thing so wahts the friggin point if you use one or the other? Other then the fact that SDL and Allegro are much easier and better to use?

Share this post


Link to post
Share on other sites
Quote:
Original post by Lazy Foo
Quote:
Original post by Unknone
Don't get me wrong, SDL and Allegro look great. But I don't want to get into the habit of using another 3rd party library or engine because then you can't program properly without them. That's why I don't use graphics engines and anyway, I've already looked at OpenGL. But I need to go to the Win32 API to learn certain things, such as how to load up a bitmap WITHOUT any engines or anything. I will still probably learn SDL and Allegro, but that will be after I have a reasonable to good knowledge of the API. Thnx for the help though.


I have to say you have some screwy definitions for the terms 'API' and 'Engine'.


Lol. I probably do. I wouldn't be surprised. Define "screwy" in this context.

BTW, I take back about 1/2 of what I said about SAMS Teach Yourself Game Programming in 24 Hours. After a while of staring blankly at the screen and trying to work out the bits I was having problems with, I relised that it gives a slightly better description then I thought. Not quite good enough, but I'll look at it a little while longer. Please anyone who actually understands this book explain the Bitmap.cpp to me :)

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