Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Thidranki

macrumors member
Original poster
Apr 7, 2005
94
0
Virginia
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

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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

Moderator emeritus
Jun 25, 2002
15,698
1,872
Lard
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

macrumors 6502a
Apr 30, 2002
528
48
NH
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

macrumors 6502a
Apr 30, 2002
528
48
NH
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

macrumors member
Original poster
Apr 7, 2005
94
0
Virginia
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 :eek: )

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?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Thidranki said:
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 :eek: )

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

macrumors member
Jul 22, 2005
46
0
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

macrumors 604
Aug 2, 2002
6,607
716
Cork, Ireland.
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

macrumors 6502a
i'm in the same boat as you Thidranki,

i've been learning C++ and i highly recommend the book Beginning C++ Game Programming 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, but i think i'm going to try some SDL first cause it's a lot easier than OpenGL 3D stuff.
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
Thidranki said:
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 :eek: )

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

macrumors regular
savar said:
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

macrumors 6502
Jan 17, 2002
480
132
Santiago, Chile
savar said:
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.
 

makeme

macrumors member
Jul 16, 2005
48
0
Professional C / C++ Programmer's Bookshelf

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

macrumors regular
Jan 20, 2004
160
0
While we're at it, I'll throw in Bruce Eckel's Thinking in C++, which is available for free at mindview.net . 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 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

macrumors member
Jul 16, 2005
48
0
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.