   Complete Beginner.
  Hey,I'd been wanting to post this for a few days but I had some registration problems.I've always had a real interest in game development, but it's never been something I've ever really delved into. I began to give the idea of game development when I saw the Torque Engine, it seemed cheap enough to purchase and make games on without having to worry about being thrown right into the deep end.My funds are a bit tight at the moment and I may as well wait till I get my new pc in late January before going near Torque. I read through a few of beginner articles, which have reassured me a bit seen as alot of the articles I've read recently seemed to working on a slightly higher level than I was at.I don't have any programming experience at all (Unless HTML count, in whichcase I have a small knowledge of html)So the two questions I'm asking are,1. Aside from the beginner tutorial pages. Are there any online tutorials that go through the basic starting games mentioned in the game dev articles? (Tetris, Pacman, Breakout e.t.c.)so I can start feeling my way into C++? And am I correct in assuming I can get started with a text file and a freeware compiler? Or will I need something more sophisticated?2. This is a little more wishful thinking.The main reason Torque caught my eye was because secretly there's been a game I've always wanted to create on the pc. Basicly a much better version of the RPG I made when I was twelve. Now I'd love even more to make that into a MMORPG. But I realise that I'm very far away from that.However Torque supports 128 players in it's released state with the option to code in more.Once I'm comfortable with Torque and C++. I'd like to start the rpg game, now would it be a good/feasable idea to start the game as a very basic FPS. Put in some scenery, some bad guys, a couple of weapons. And then build from that in small increments? I.e adding more complex stats in, instead of just health, strength and agility. Then work on increasing the RPG elements very slowly whilst increasing the content appropriately?Thanks :)   
  I would just start out learning C++ first(or whatever language you choose to use) before touching game programming topics.  I learned that the hard way.  When I first started programming I was like "oooo, loops, I can program anything now".  This is strngely ironic, though, due to the fact that games depend on a game loop, lol.  But it's what's in the game loop that makes the game.  But anyway, I'm getting slightly off topic.  Grab yourself a good programming book(see Books section of this site for good options) and get familiar with programming and related techniques in general, then move on to more advanced topics, such as game programming.  Hope that helps.-AJ   ;  First off, I hate getting the run around so I am going to get straight to the point. There is a lot to learn, but please don't get discouraged when someone tells you to do something like learn c++ before trying game programming. Learn why they say what they say. Unlike other post I am going to give a more in depth pathway to games.There are a number of paths you can take the recomended path is 1. Learn a programming language.2. Learn an  graphics library.3. Apply what you have learned.(make $$$)First there is learning a language. The big hog at the trough these days is c++. Some people prefer C, but as you may soon learn, Bjarne Stroustrup( the author of the language) and several others recommend that you do not learn c first, so just learn C++ and save yourself time and just learn C++. I am not going to cover it all, but I am going to give you a rundown of c++.The simplest C++ program you can write is #include <iostream>using namespace std;int main(){    cout << "Hello World" << endl;    cin.get();    return 0;}#include  tells the compiler that you want to include a file. We put this first in a file, so that the file is included before we get to our source code. The reason for this is that we have to use some stuff that we haven't typed yet. That stuff is in another file, and we have to include it so that we don't get an error.<iostream>   this is the file that contains the declarations for the stuff we are going to use.#using namespace std; // need for one thing only, so that we don't have to type    // the std:: prefix infront of everything from the   //standard library defined in the iostream file.int main() //this tells the compiler where to begin.{  // this brace delimits code. that means that  the stuff we declare in this //section will be availible only in this section, and nowhere elsecout  // tells the compiler that we want display some letters on the screen<< // insertion operator"Hello world" // Is what we want to show on screen<<   // Insertion operators  must be used if we want to show more than // one thing onscreenendl // is short for end line and tells the compiler that we want any word after// endl to be on the next line down. It's like using the return key.   cin.get(); // carry over from C. basically it tells the compiler to pause.   // if you don't add it the program may close and you won't see your   // out put.   return 0; // Signal to the operation system that everything is ok} // closing brace. Braces must be in pairs or you will get an error. Some other things you will learn in c++ are:variablesa variable is a location in memory, in which you store a value, and from which you later can get that value back. Think tupperware, you put something yummy inside, and later on (midnight is a nice time) you can that snack back. In C++ you must declare a variable before you can use it. You declare a variable by declaring it's type and the name.int a = 0;The word int is a datatype, it tells the compiler the type of data we are going to use. “a” is the name of the variable, and it can be any given  value. This is kind of a catch 22, because even though you can use any number, certain types are limited in the number that you can store in them. The reason for this is the way that memory is assigned by the compiler. there are 7 data types and each type has a specific range of numbers you can store in it. You have to tell the compiler what type of variable you want to use.Please don't let the word "type" throw you for a loop. It is just a fancy way of saying what kind of data variable can hold. Different kinds of variables can hold a different range of numbers.(forgive me programmers if I get the numbers wrong)assumming these are unsigned.short = 0 - 65,535;so if you declared a short variable like thisunsigned short a; you can only hold a  number between 0 - 65,535you can also use unsigned and signed keywords. Unsigned means that the variable can hold only positive numbers. signed means it can hold positive or negative numbershow can you tell the difference, unsigned numbers have a - in front of them. Capice. 455 positive number.-455 negative number.operatorsAn  operator is a symbol that causes the compiler to take action.there are 45 operators in c++ I believe. Some of which are:+-*/()[],->?.just to name a few.keywordsThere are a whopping 65 keywordsasm  // allows you to type assembly language.auto // declares a variable to be have a starting valuebool // a data type that is in either one of two states true or falsebreak // this keyword is used to get out of a loopcase  // catchcharclassconstconst_castcontinuedefaultdeletedodoubledynamic_castelseenumexplicitexportexternfalsefloatforfriendgoto if inline int, long, mutable, namespace, new, operator,private, protected, public,register,reinterpret_cast, return, short, signed, sizeof, static, static_cast, struct, switch, template, this, throw, true, try, typedef, typeid, typename, union, unsigned, using, virtual, void, volatile, wchar_t, while expressionsfunctionsThis is a useful feature in c++ that prevents you from having to retype code over and over again. Let’s say you want to create a program that displays a welcome message to all the guest you invited to your home(You may not have a home, or you may be a party pooper, but for now let's just suppose) you could type: char guestname[] = whateveryourguestisname;(And no you cant do that, in the first place that is not inside quotation marks, so the compiler will yell at you, in the second place that is a very stupppid name. In order to get it to work, you would have to replace whateveryourguestisname with something in " ", like char guestname[] = "Mark", or "billy" , or whatever just so long as it is in " ")cout << "Hello" << guestname << endl;This works ok if you have 5, 10, 15, or 20 guests; however, if you're P. diddy you got an entirely different situation altogether :), it's even worse if those guest invite their friends,and they invite their friends (You do still have that chiropractor's number right? :)). If you want to avoid heavy doctor's bills  you could use a function. Functions make using the same code  easy, you just write a function and every time that function is called the code executes saving you time. Here is how to declare a function.datatype functionName(arguments, arguments);A datatype is anyone of the seven types in c++bool.int.short.double.float.long.char.And a function name can be any name provided it does not begin with a number and there are no spaces in between any of the letters.here is a function for the guest we invited earlier.int Greetguest(char * guestname){ cout << "Hello " << guestname << endl;}Now all you have to do is write the name of the guest and call the function, like this: Greetguest("Mark"); // Mark can be changed to whatever your guest name is.PointersThis is the simple guide to pointers. They hold addresses. Period. Every variable you declare is given an adress in memory, which is located in the ram on your computer, this is where it is held during program execution. If you want to acess the value of that variable you can use a pointer. So let’s say you want to access a variable you declared earlier. int a = 5;you could declare a pointer to it.int * pInt = &ayou must use the * in between the pointer name and its type and you have to use the & before the variable address you are trying to access.references They are the same as pointers with a much easier syntax just use the & instead of the *. A reference is declared like this.int & r = a;you don't need to use a & in front of a, because this is a reference and not a pointer.classesThis is one of the main highlights of C++. you can combine variables and functions all under one rooftop.class myClass{public: // This is a keyword that tells the compiler that we want every   // part of our program to be able to access this.int a;  // a variablevoid SetA(int change); { a = change;};  // This is just a function that // change a};variables in a class are called, member variables and functions in a class are called member functions. The benefit is that it is all in one place. You can use a class the same. There are three keywords that apply to classes.Private, protected, public;private means that only functions of the class can use the variables in the classPublic means that any part of the program can use anything in a classProtected means that only the derived classes(described next) can use the things declared in the private section. inheritance  this means that if you have two classes. The members of the second class can use the functions in the first class. You can use the members in one class in another class. The first class is called the base class, and the second one is called a derived class.polymorphismPolymorphism is a greek word that means, “Many forms” , in a class it means that You can change  a function declared in the base class, in a derived class.  So if we had a class:class myClass{int a; public: void SetA(int change);};class AClass:public myClass{};we could change the SetA function declared in myClass inside of AClass.TemplatesThese are generic functions.This is a very basic intro to c++, and I am sure some of the people on gamedev are going to throw a fit,so if you just have to comment please do.Here are some good sites to learn c++. http://www.functionx.com/cpp/index.htmThis site has a almost 23 tutorials on C++. Each lesson contains full source code, so all you have to do is just read and learn. They also have downloadable e-books  if you want to read them offline.To get the most out of programming save yourself some trouble and use an integrated development environment, I.d.e for short. An Ide is a mixture of a compiler, linker, and text editor, it makes it easy to type, edit , and debug source code( the fancy name for the c++ code you type).  I recommend using dev C++.  www.bloodshed.net/devcpp.html. DevC++ is free and it is a good ide ta-boot. It can even do Win32 applications, which is what you will need to make a games on windows. There is also Codeblock's ide it is free as well and can be downloaded from www.codeblocks.org. An added benefit of an ide is syntax highlighting, which may change a keyword into a particular color to let you know that word is a keyword.The next step is  graphics. C++ doesn’t have support for graphics, so you will need an application programming interface, or a graphics library. A.P.I for short,there are a number of api’s available;however,the two big ones are Directx  and opengl. There are several componants to directx, but the main component of directx, which we are concerned with is called d3d.I am not going to go into the whole Opengl is better than d3d thing I think only someone who is advanced in using a graphics would be skilled enough to  notice the differences anyway. I don't think Opengl is easier than d3d, I think direct3d is just different. I would put the code for d3d initialization in this post, but that would get me in trouble, so here is a rundown on some of the strengths and weaknesses that I have found in both.first off 3d is short for 3 dimensions. in 2 dimensions or 2d you have width and height, which is great for a side scroller, but it lacks, well, depth and that is where 3d comes in. Going from the bottom of the screen diagonally to the top of the screen adds the illusion of depth. That’s a very short explanation of a very complex subject of 3d graphics. Anyway,Most 3d api's have support for the following operations:drawing primitives  // this is where we get to see somthingTransformations    // I like to move it, move it. You like to move it?lighting // It would be very dark without this fog// Not just for creepy graveyards, but also can be used for // reducing the complexity of a scene.Direct3d and Opengl are no exceptions.  However, each implements these differently. I will start with direct3d.Direct3DHere are some of the pros.D3D can do everything Opengl can.D3D is Updated regularly.Very powerful.Easy to use shaders.Has a format for loading 3d models.// Warning the following section will use actual d3d code. For more //information consult the D3D documentation.D3D Has a very easy Setup.(You can get d3d9 up and running in 30 lines or less.)D3DPRESENT_PARAMETERS d3dpp;ZeroMemory(&d3dpp,sizeof(d3dpp));d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;d3dpp.Windowed = true;d3dpp.backBufferFormat = D3DFMT_UNKNOWN.pd3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp, &pd3ddevice);(here is a tip if you want to see d3d in action. After you install the d3d sdk go to C:\Program Files\Microsoft DirectX 9.0 SDK (October 2005)\Samples\C++\Direct3D\Tutorials. This contains all source code contained in documentation.  Or just look at the sample browser)consEverything uses interfaces. If you don’t know what an interface is, I think it is a pointer to a class.You have to declare a lot more, before you can use anything.The documentation is huge.It's different. You have to go through more to get something up on the screen. Here’s a little code to get 1 triangle up on screen.1. Declare struct2. Use struct3. Render. That is not as easy as it sounds. And this code is minimal// This is actual codeLPDIRECT3DVERTEXBUFFER9 vb;struct CUSTOMVERTEX{float x,y,z;DWORD Color;};bool InitVB(){CUSTOMVERTEX vertexStructure [] = {{1.0f,-1.0f,0.0f,D3DCOLOR_XRGB(255,0,0),},{-1.0f,-1.0f,0.0f,D3DCOLOR_XRGB(0,255,0),},{0.0f,1.0f,0.0f,D3DCOLOR_XRGB(0,0,255),},};pd3ddevice->CreateVertexBuffer(sizeof(CUSTOMVERTEX)*sizeof(vertexStructure),0,D3DFVF_DIFFUSE|D3DFVF_XYZ,D3DPOOL_DEFAULT,&VB,0);}void Render(){pd3ddevice->Clear(0,0,D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),0.1f,0);pd3device->BeginScene();pd3device->SetFvF(D3DFVF_DIFFUSE|D3DFVF_XYZ);pd3device->SetStreamSource(0,VB,0,sizeof(CUSTOMVERTEX));pd3device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,1);pd3device->EndScene();pd3device->Present(0,0,0,0);}get the point.OpenglPros:Opengl can get up and running quicklyEasy to declare vertices. And render we’re talking:glBegin(GL_TRIANGLES);glvertex3f(1.0f,-1.0f,0.0f);glVertex3f(-1.0f,-1.0f,0.0f);glVertex3f(0.0f,1.0f,0.0f);glEnd();glSwapBuffers(hdc);and boom you can see a triangle being rendered. To do the same thing in d3d, you would also have to set up a camera. Which is not much more work, but it goes to show  you a difference between d3d and gl.cons:1. It is not updated to often, so you may not be able to use the latest stuff.2. It takes a while to get used to the set up of a window. In opengl these are the steps to take. A. Declare pfd structure./* a structure is like a class, in fact the onlydifferance between them is that all structures are public by default.*/B. GetDC;/* A device context contains information concerning the drawing states used by windows*/C. get RcD. make current.3. Releasing resources is a pain. Because you may forget to do it, and cause a memory leak.finally apply what you have learned. If you learn an api you should easily be able to start on a game. Other areas you need to look into are.SoundCollision Detection.Physics.Well if you got to this point congratulations. If you think it took a long time to read, it did. :)  Anyway you should now have enough knowledge to get started. If you want to read several tutorials on d3d and opengl keep an eye on my site http::/dayiscomming.bravehost.net[Edited by - cellman on December 12, 2005 5:15:43 PM];  why did you just write a tutorial as a response to a simple post? just curious. good info, just blows me away.   ;Quote:Original post by cellmanThe simplest C++ program you can write is #include <iostream>using namespace std;int main(){    cout << "Hello World" << endl;    cin.get();    return 0;}Actually, the simplest C++ program you can write is int main() {}. [grin]And that would happen to be the source code for the UNIX true command (if you ignore the command-line options to display help and version that are specified in the man page). [smile]   