Sign in to follow this  
l jsym l

Any Good Books?

Recommended Posts

Hey, I dont know how many times i"ve been on this website looking for good books and whatnot but i have a few books that just dont seem to sum anything up. I was just wondering if anyone knew of any good books that will help me learn Game Programming in C++. It would be really greately appreciated.... Also, im not trying to steal anything or anything, but was wondering if someone could give me a sample code of a little game they made previously just so i Can see what The code of a game actually looks like. It can be the littles game ever. I just want to get a start because i'm in love with video games and am very passionate about creating them and beginning a career in game develpment. Thanks :)

Share this post


Link to post
Share on other sites
Hello,

For graphics:
Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach
Introduction to 3D Game Programming with DirectX 10
both by Frank Luna

Other game programming:
Beginning OpenGL Game Programming
Beginning Game Programming

Share this post


Link to post
Share on other sites
First off, you need to understand that game development is a huge proposition. Yes, you can (and probably should) start with a simple 2D game like pong to get started --- unless you already have a vision that is massively important to you already. Sadly, most books that tried to give a good fundamental understanding of game architecture are very old books, OR they are manuals-for or promotions-of existing game engines. I recall an old book written by someone with a name remotely similar to Andre LaMothe or thereabouts that was good. Maybe you can find a used copy real cheap from an online bookstore.

The best overall book for real time rendering of 3D is called "Realtime Rendering". This book is not specifically about game development, but 99% of the contents is totally relevant to understanding 3D graphics, game engines, game engine design and development, GPUs, etc.

If you prefer to adopt OpenGL (which I believe is wise), then two books about OpenGL are far and away the best: "OpenGL SuperBible" and "OpenGL Shading Language". Also download these free PDFs: OpenGL v3.10 and GLSL v1.40 specifications at <http://www.opengl.org/registry>.

If you just want to understand the basic "game loop" at the heart of essentially every game, just google "game loop" (in double quotes). I just tried this, and several good descriptions and discussions and articles appeared in the top 20 spots. The best example in the top 20 is: <http://dewitters.koonsolo.com/gameloop.html>. Try to avoid examples tailored to a specific 3D graphics API until you understand the general points.

A game is essentially a real time simulator or robotics application. Take input from an operator. Compute changes to the objects and environment your application simulates (games/simulators) or controls (robotics). Display a visualization of those changes. Begin again until something shuts the game/simulation off.

Most important, don't think you can hold a detailed understanding of the entire process of a game in your mind. Once you get past the top level "game loop", most everything is simply a special purpose subsystem that knows little or nothing about the rest of the game or game-engine. That's called encapsulation/modularization/factorization, and you better become an expert at that, or your games must stay small and simple. A game is a large to huge endeavor. Expect to take months or years to get anything [significant] done. I hope this helps.

Share this post


Link to post
Share on other sites
I have to agree with maxgpgpu on the simple fact that there are so many 'game programming' books out there that go into specifics about various things but 1) assume that you're a beginner to how computers work in the first place and 2) have some of the most hideous code examples I've ever seen. The problem with these books is that they try to sum up everything involved in game development into a few short chapters. Unfurtunately, this has the effect of promoting bad programming habits and a poor understanding of software design which, while not needing to be nearly as exhaustive as, say an operating system, is a very important part of any application programming process.

Too many times I see amature games with code that might as well have gone through a meat grinder. While "it works", defects are a serious problems with most of these games and many times poor design leads to various other problems (ever notice how many game projects only get so far before they fizzle out and are never finished? There's a reason for that).

Anyway, along with learning how to use existing code (e.g., SDL, OpenGL, OpenAL, Ogre3D, etc.), one must also understand, at the very least, the basics of software design principles. A good book for this is Code Complete. I have revision 3 and I find particular use in the PDL section of the book. Software design is a fundamental part of developing software and too many beginners get into the mindset of "I'm going to sit down today and write a game!". This works for very trivial games but the second you want to get into anything that's less than trivial you're going to run yourself into a wall. Guaranteed.

I hope I'm making sense because it's late but suffice it to say that besides learning how to use various already available API's (it's a lot better to use existing software that's thoroughly tested and proven to work, no sense reinventing the wheel) which you can learn using the thousands upon thousands of resources across the web (including GameDev) and at the same time learn about designing software.

Hope this helps and good luck!

[EDIT]
I forgot to comment on your point about seeing game source code. Your best bet is to look on an open-source software host like SourceForge or Oholo for something like that. Good luck. If you want to look at some industrial strength code, go download the source code for Quake2 or Quake3Arena. Neither of these are trivial but it's a great way to learn practical application of concepts (just note that Q2 was written in C, not C++, not sure about Q3A). I'm sure others know of some good things to look at that might be more suited to your level.

Share this post


Link to post
Share on other sites
Quote:
Original post by l jsym l
if someone could give me a sample code of a little game they made

#include <cctype>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>

int random_number_between(int lower, int upper)
{
const double squeeze = 1.0 / (RAND_MAX + 1.0);
int range = upper - lower + 1;
return lower + int(rand() * squeeze * range);
}

std::string read_line()
{
std::string line;
std::getline(std::cin, line);
return line;
}

int read_number()
{
std::stringstream ss(read_line());
int number = 0;
ss >> number;
return number;
}

class Game
{
int number;
int last_guess;
int attempts;
public:
Game(int number) : number(number), last_guess(0), attempts(0) {}

void guess(int guess)
{
last_guess = guess;
++attempts;
}

bool guessed_wrong()
{
return last_guess != number;
}

std::string feedback()
{
if (last_guess < number)
return "Too low!";
if (last_guess > number)
return "Too high!";

std::stringstream ss;
ss << "You guessed correctly after " << attempts << " attempts!";
return ss.str();
}
};

void guess_the_number()
{
std::cout << "\nWhat number am I thinking of?\n";
Game game(random_number_between(1, 100));
do
{
game.guess(read_number());
std::cout << game.feedback() << std::endl;
} while (game.guessed_wrong());
}

bool play_again()
{
char c;
do
{
std::cout << "Do you want to play again? ";
c = tolower(read_line()[0]);
} while (c != 'y' && c != 'n');
return c == 'y';
}

int main()
{
srand(time(0));
std::cout << "Welcome to GUESS THE NUMBER\n";
do
{
guess_the_number();
} while (play_again());
}

Share this post


Link to post
Share on other sites
Quote:
if someone could give me a sample code of a little game they made previously

I have a little game that might inspire you. It may be a silly little thing, but I like it never the less. Being a puralist I actually consider it one of my best games. I even finished it...


#include <string>
#include <map>
#include <iostream>
using namespace std;

struct Location
{
map<string, Location*> exits;
string description;

friend ostream& operator << (ostream& out, const Location& loc)
{
out << loc.description << "\nPossible exits: ";

for(map<string, Location*>::const_iterator i = loc.exits.begin(); i != loc.exits.end(); i++)
out << i->first << " ";

return out;
}
};

int main()
{
string userCommand;
map<string, Location*> world;

// create locations
world["start"] = new Location;
world["start"]->description = "Start location...";

world["farm"] = new Location;
world["farm"]->description = "You are at the farm...";

world["town"] = new Location;
world["town"]->description = "You are in the town...";

// setup links between locations
world["start"]->exits["town"] = world["town"];
world["farm"]->exits["town"] = world["town"];
world["town"]->exits["farm"] = world["farm"];

// setup current location
Location* location = world["start"];

while(true) // The game loop
{
cout << *location << endl;

getline(cin, userCommand);

if(userCommand == "exit")
break; // Exit game loop

map<string, Location*>::iterator lookup = location->exits.find(userCommand);

if(lookup != location->exits.end())
location = lookup->second;
else
cout << "Invalid exit." << endl;
}

// release memory
for(map<string, Location*>::iterator doe = world.begin(); doe != world.end(); ++doe)
delete doe->second;

return 0;
}



Regarding books. Most game development books, at least the decent ones, will assume that you are familiar with C++ already, and that you are ready to jump into deep water, like graphics, threads, AI, networking etc.

If you are not ready for that yet, your best bet is to start with a book that will teach you pure, plain C++.

A couple of books i like:
- C++ Primer
- Effective STL

Share this post


Link to post
Share on other sites
Hey thanks for the sample codes :) they helped out a bunch. So the effective stl book...is that teaching of c++ stl or what. sorry. I'm a beginner of game programming in c++ but i have a weak background and know the beginnings of it.
THanks :)

Share this post


Link to post
Share on other sites
Yes, I would say it's kind of a "Best Practices" book about C++ STL. Not the first book I would read, but definitely the second. If you know what I mean. In fact, all the books by Scott Meyers is great IMO.

PS.
I'm going to dodge a bullet here and mention that the term STL is getting old. It is commonly referred to as the C++ standard library now.

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