PDA

View Full Version : Game Programming - - - - Help




Thidranki
Apr 7, 2005, 02:06 PM
I know very little about programming. When reading some of these posts, it is a different language to me. I've been doing a little research about programming though. I've decided that I want to program 3D games.

I read a little about Game programming, and the language suggested was C/C++. It also included some things about algorithms, AI, graphics etc...

Anyways. I won't have access to the internet for two months and I want to know first of all if C/C++ is the best language, and where I can get a compiler and what I should physically write the language in for Mac.

Thx a lot. :D



robbieduncan
Apr 7, 2005, 02:25 PM
You simply cannot just dive straight into 3D games programming. You need to learn the basics first. Unless you know how to set up data structures, control program flow and debug your code at a minimum you are just going to get annoyed and upset.

Having said that most professionally developed games are written in C++ using either Direct-X or Open-GL to provide the graphics. As only Open-GL is available on the Mac that's what you'll be using. Open-GL is fairly simple to get started in, but difficult to get the most out of.

In terms of what to program with install the developer tools that come with every Mac (and copy of OSX). Fire up XCode and open some the Open-GL samples. Now buy a book on learning C++ and read it and do EVERY example. XCode is an IDE so it has a reasonably nice programming text editor compiler and everything else built in. The developer tools also include the standard command line compilers so you can use any other text editor you choose if XCode is not for you.

If you get this far try writing some 3D example programs to get a feel for how it works. An Open-GL book would be good here.

bousozoku
Apr 7, 2005, 02:29 PM
C++ is a reasonably good language for it, but you have to be diligent in making sure that everything is balanced. You allocate something, use it, and dispose of it when you're done. A lot of the problems with C++ programming come from someone not being methodical in this. They try to use something not yet, or no longer, allocated.

C++ and OpenGL is certainly a good combination to use for both Mac and Windows programming but there will always be certain platform-specific details that you should hide by using of compiler directives to make your cross-platform life easier.

Pismo
Apr 7, 2005, 02:42 PM
C++ is the language of choice because it's object oriented. C++ is a great language to learn but I think it's going to be a while before you can dive into 3D games. I took an OpenGL class in college and learned about sprites and collisions. It wasn't easy. It was an advanced upper level class but it was an intro to game programming. There are programming books out there written specifically for gaming but I think they expect the reader to have a good understanding of programming. Good luck!

Pismo
Apr 7, 2005, 02:51 PM
I forgot to mention that you need to have a good understanding of memory allocation and memory usage. A guy in my OpenGL class made a very simple game but he didn't do a very good job with memory usage. He had a gig of RAM in his computer and the game seized up his computer because the game was using the rest of the RAM and bogged his system down. Good thing the professor showed him how to fix the problem. Same thing applies with memory on video cards (in my experience). My professor made the game engine and tuned it to run better on NVidia cards. Good thing my PC had an NVidia carrd. There are countless thing to take into consideration when making a game, no matter how simple it is.

Thidranki
Apr 7, 2005, 05:26 PM
I know that I can't just dive into 3D games, i was planning to learn C/C++ with some books on my own this summer, and go from there. I was wondering if i should learn C first or just go striaght to C++. I have no coding experience (just some minimal experience with html :o )

I doubt I will get to memory usage and Open-GL anytime soon, although that would be cool.

BTW, what college did u go to Pismo?

SilentPanda
Apr 7, 2005, 06:18 PM
http://www.createmacgames.org

Although I'd start with the basics as recommended above.

robbieduncan
Apr 8, 2005, 04:16 AM
I know that I can't just dive into 3D games, i was planning to learn C/C++ with some books on my own this summer, and go from there. I was wondering if i should learn C first or just go striaght to C++. I have no coding experience (just some minimal experience with html :o )

I doubt I will get to memory usage and Open-GL anytime soon, although that would be cool.

BTW, what college did u go to Pismo?

If I had my way everyone who wants to program would learn C. It teaches you an often used syntax but more than that it enables you to learn how the machine works. As a base to learning C++ it's probably a very good idea to learn C, but it's not required and you will learn a load of stuff that you will stop using when you use C++ properly.

SpiffyChee
Jul 22, 2005, 09:39 AM
I am in the exact same boat as him, I have a huge book on C++, but it is a pc book, will it still work for me?

whooleytoo
Jul 22, 2005, 10:52 AM
I'd agree very much with what robbieduncan said above, you have to start off with something simple and work your way up (patiently! ;) )

When you're starting off, it's far more worthwhile to pick an easy project and finishing it than trying something more ambitious and getting bogged down in the nitty gritty. The morale boost from finishing your first game - regardless of how simple it might be - is very rewarding!

Obviously, you need to learn the basics of programming, but then I'd recommend a simple, 2D sprite based game. Most games like this have a simple overall structure:

while (game isn't complete)
get user input
calculate new player position
calculate new other-sprite positions
detect collisions
draw player & sprites

Getting user input is easy, there are various documented ways of reading which keys, modifier keys (Command, Option etc..) are pressed, as well as mouse movement.

Calculating the player position simply involves changing the co-ordinates you have stored for the player, if the right arrow is pressed, increase the x co-ordinate by a fixed amount, etc.

You'll have to figure how other moving sprites in the game determine their next move - do the little green men rush straight towards your character, and how fast, or do they move randomly about?

Then you need to detect collisions. Is your character trying to run through a wall? Does one of the little green men's bullets co-ordinates coincide with your player's co-ordinates?

Then, based on the previous steps, you draw all the sprites in their current positions. If they're all static sprites (like, say, spaceships), it's quite easy. If they're animated (such as a character walking), you'll need to have several pictures("frames") of the character, and keeping drawing the next one while he's moving.

There are other factors to consider then, such as how fast will the game play - you'll (eventually) need to add some kind of timer functionality so that it plays at a regular rate on both fast and slow computers. You may want sounds, and background music.

One piece of advice, try - as much as possible - to read in settings like 'player speed' from a text settings file, that way you can just change it by hand and run the program again, instead of having to make code changes.

Best of luck!

(Incidentally, I'm told one of the best ways to get into 3D programming these days is to start by making game mods for games like Unreal Tournament, or Quake 3. Once you have a handle on programming, it might be worth a look).

ExoticFish
Jul 22, 2005, 12:33 PM
i'm in the same boat as you Thidranki,

i've been learning C++ and i highly recommend the book Beginning C++ Game Programming (http://www.amazon.com/exec/obidos/tg/detail/-/1592002056/qid=1122053131/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/002-4094768-9253629?v=glance&s=books&n=507846) which is good cause it's platform independant so everything will work on whatever platform you choose.

i've only got 1 chapter left of that book so i picked up Beginning OpenGL Programming (http://www.amazon.com/exec/obidos/tg/detail/-/1592003699/qid=1122053410/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/002-4094768-9253629?v=glance&s=books&n=507846), but i think i'm going to try some SDL (http://www.libsdl.org) first cause it's a lot easier than OpenGL 3D stuff.

DavidLeblond
Jul 22, 2005, 01:16 PM
i've only got 1 chapter left of that book so i picked up Beginning OpenGL Programming (http://www.amazon.com/exec/obidos/tg/detail/-/1592003699/qid=1122053410/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/002-4094768-9253629?v=glance&s=books&n=507846), but i think i'm going to try some SDL (http://www.libsdl.org) first cause it's a lot easier than OpenGL 3D stuff.

You can also stick with SDL when you venture into OpenGL. That way you have a cross-platform game. SDL is good stuff.

savar
Jul 22, 2005, 06:03 PM
I know that I can't just dive into 3D games, i was planning to learn C/C++ with some books on my own this summer, and go from there. I was wondering if i should learn C first or just go striaght to C++. I have no coding experience (just some minimal experience with html :o )

I doubt I will get to memory usage and Open-GL anytime soon, although that would be cool.

BTW, what college did u go to Pismo?

Nobody has mentioned it yet, but developing games also requires good math skills.

For 3d games, you specifically need to be strong in vector algebra, and I suspect vector calculus as well. It also wouldn't hurt to have taken a course in algorithms and data structures, because games make heavy use of the kinds of algorithms and data structures that are typically taught in a good intro comp sci course.

aquanutz
Jul 27, 2005, 09:26 AM
Nobody has mentioned it yet, but developing games also requires good math skills.

For 3d games, you specifically need to be strong in vector algebra, and I suspect vector calculus as well. It also wouldn't hurt to have taken a course in algorithms and data structures, because games make heavy use of the kinds of algorithms and data structures that are typically taught in a good intro comp sci course.


Yeah, that's why I steer clear of 3d game programing. My mathematics is so weak it's not right. It's something I have to work on if I ever want to get serious about 3d.

colocolo
Jul 27, 2005, 09:45 AM
Nobody has mentioned it yet, but developing games also requires good math skills.

For 3d games, you specifically need to be strong in vector algebra, and I suspect vector calculus as well. It also wouldn't hurt to have taken a course in algorithms and data structures, because games make heavy use of the kinds of algorithms and data structures that are typically taught in a good intro comp sci course.

I totally agree, and I would even go as far as to say that if you really want to do a serious program, it is a must to have a developed mathematical and logical way of thinking.

It helps so much to design the adequate data structures and to design intelligent and efficient solutions, that I could not imagine doing so if you can't really embrace the "abstract".


If you are serious into programming, I would recommend getting into related topics at the same time you try to pick up your C++ skills, like maybe computer architecture (it's always nice to know what the computer really does), automata theory (you know, Turing and all that), data structures (too important), and maybe some programming concepts such as calculating O(n) for your functions, so you can just look at the code and know what solution would be the most efficient.

ChrisBrightwell
Jul 27, 2005, 10:12 AM
C++ is the language of choice because it's object oriented.Calling C++ OO is just funny to me. OO is an afterthought for them.

makeme
Jul 28, 2005, 06:38 PM
I don't do any game programming, but I would assume that you should learn the language first anyway. So, for what it's worth here are some of the books I've read and refer to frequently as a professional C / C++ programmer. Throw in some excellent game, graphics, artificial intelligence and OpenGL books and you should have everything you need.


The C Programming Language by Brian Kernighan and Dennis Ritchie
The Standard C Library by P. J. Plauger

Algorithms in C by Robert Sedgewick (This is a set of books)
The UNIX Programming Environment by Brian Kernighan and Rob Pike

The Practice of Programming by Brian Kernighan and Rob Pike
Expert C Programming by Peter Linden

The C++ Programming Language by Bjarne Stroustrup
The C++ Standard Library by Nicolai Josuttis

Effective C++ by Scott Meyers
More Effective C++ by Scott Meyers
Effective STL by Scott Meyers

Exceptional C++ by Herb Sutter
Exceptional C++ Style by Herb Sutter

C++ Gotchas by Stephen Dewhurst
C++ Coding Standards by Herb Sutter and Andrei Alexandrescu

rinseout
Jul 29, 2005, 01:05 PM
While we're at it, I'll throw in Bruce Eckel's Thinking in C++, which is available for free at mindview.net (http://mindview.net/Books/TICPP/ThinkingInCPP2e.html) . I still think this is one of the best-written computer books around.

When you get into serious programming, you will occasionally encounter issues with the language which, fortunately, have usually been encountered before. I find myself reading parts of the C++ FAQ (http://www.parashift.com/c++-faq-lite/) about once every three or four months. I first encountered it when I found myself wondering how to get something like a "virtual friend" member function, which is not provided for in the language. (But it turns out you can get the behaviour you're looking for easily).

makeme
Jul 29, 2005, 01:49 PM
The FAQs really are excellent free resources, I can't believe I forgot to mention them. I was just too busy focusing on books, I guess. Here are the websites that I would be lost without.

http://www.eskimo.com/~scs
The C FAQ as well as lesson plans, lecture notes, assignments and their solutions from Steve Summit who taught Computer Science at the University of Washington.

http://www.research.att.com/~bs
Bjarne Stroustrup's website with a C++ FAQ, papers and articles as well as errata and code examples from his book.

http://www.dinkumware.com
Complete, free and up to date C and C++ standard library references.