# My first game

## Recommended Posts

Hi everyone. I've read some tutorials on this page, from whuch i know that ishould use c or c++ for making games. I also know that for first game i should make something similar to tetris. Graphics are not the problem because i have some basic knowlege about photoshop, and 3ds max which i guess will be no of use at least for now. And here's my question: what is the best site with tutorials for the beginners, and are there any free books over the web i could read? Still i'm going to by a book anyway but as i'm programing noob it's hard for me to say which one suits my needs better. Thanks for everyone who will try to help me.

##### Share on other sites
Try the Forum FAQ

Also TickTackToe is an easier game to code than Tetris.

C and C++ are not essential for game creation, many ppl also recommend C#, Python, VB. Go with what you know the best or can learn the easiest.

If you are going the C/C++ way have a look at SDL.

My best advice I can give you is learn your language first and code as much as possible ... the more experience the better.

##### Share on other sites
After you learn some C/Cplusplus you should look into SDL.
SDL
It's an easier way to get started with video, music,
and input in games.

##### Share on other sites
programming guru's seconds edition
need a baic understanding of c or c++
great book, only book I ever read on games that actually makes a text adventure with u
it also covers 2d and 3d
it's easy to understand
I bought like 7 books from barnes and noble in like last year and it's the best

##### Share on other sites
Thanks to all of you for so quick replies I'll try to check or resources you have recomended.

##### Share on other sites
I have next question: what compilier should i use?
I'm searching for some free ones.
BTW: Does compiliers contain some editing tools, or do i have to write programs in notepad?

##### Share on other sites
You'll want an IDE. It contains editors and access to you compiler all in one nice package. If you want a free one, I suggest DevC++. It includes a GCC compiler.

##### Share on other sites
Hello. As for a compiler, there are some free ones that I have heard of, (http://www.thefreecountry.com/compilers/cpp.shtml) look at that website, a quick search produced it, and it seems to have some good results.

Anyway, I was able to get Microsoft Visual C++ 6.0 professional for $50 on ebay. That is, if you like 6.0 better than .net... I haven't tried .net, but I like 6.0 a lot. (.net is basically Visual C++ 7.0, with elements of Java in it I believe). If you are willing to fork over$50, then try e-bay. (May take some time to find one that low though) Otherwise, try the site I listed earlier.

Hope I helped a bit.

##### Share on other sites
That depends on your platform. If you're on Linux, you have gcc, make, emacs, and everything else in the world you need. If you're on Windows, you can still get gcc, in the guise of a (slightly arcane, but only slightly) collection of software called MinGW. If you don't want to bother with that, there's lcc, which is free, simple, and has it's own editor, but doesn't do C++.

For editors, I would recommend (in no particular order) Vim, emacs, SciTE, and Bloodshed Software's Dev-C++. If you want to solve all the problems in your life without messing around too much, get Dev-C++ with the MinGW package included, which has pretty much everything you need to start hacking C.

Do note, that if you're just starting programming, I STRONGLY suggest NOT starting with C or C++. Start with Python or Ruby or Java. All of these come in nice, easy-to-play-with packages, though having a nice editor is still a good idea. Once you're comfortable with that, THEN move on to C.

##### Share on other sites
Well, I started with C++ and it worked for me, and to me it seems like if I had learned something else first it would have severely messed me up. I am still a beginner as well, but I've got all of the basics down and am currently in the process of getting into 2D graphics like SDL, as well as advanced C++ things like the STL, pointers (as in the more advanced stuff about pointers), and more advanced object oriented stuff like polymorphisim. So... I would say start with the language you are gonna use and stick with it. Everyone is different, but from my experiance the syntax is the hardest and the concepts are the easy thing, so learning an entire language just to get the concepts down seems like a tremendous waste of time. For a compiler I'd recomend Dev-C++. To get the concepts down while also learning some syntax, The Complete Idiot's Guide to C++ is a good book.

##### Share on other sites
Thanks very much to all of you. I've downloaded dev-c++ since most of you suggested it. I must say that i'm a bit confused because i don't understand what are some of things you where talking about ;) (ex. SDL, gcc, stl or pointers).
Hope i'll learn that soon.

##### Share on other sites
Quote:
 Original post by Adams555Hello. As for a compiler, there are some free ones that I have heard of, (http://www.thefreecountry.com/compilers/cpp.shtml) look at that website, a quick search produced it, and it seems to have some good results.Anyway, I was able to get Microsoft Visual C++ 6.0 professional for \$50 on ebay. That is, if you like 6.0 better than .net... I haven't tried .net, but I like 6.0 a lot. (.net is basically Visual C++ 7.0, with elements of Java in it I believe)..
Visual Studio .Net is considered generally superior to 6 in terms of standards compliance. Furthermore, you can program in the same old C++ as 6.0. C++.Net is a completely seperate entity, fyi.

##### Share on other sites
I was learning some basics and have encountered small problem. Which type of data i need to use to declere words? I know that "int" is for numbers. Next thing is that when i try to to divide to numbers i get answer "0", why? All other operations are giving normall answers.

##### Share on other sites
I recommend Microsoft Visual C++.Net 2005 Express Edition. It is still in the beta stage so you can download it for free from MSDN's Lab site.

Degra

##### Share on other sites
Quote:
 Original post by ShugerI was learning some basics and have encountered small problem. Which type of data i need to use to declere words?

Textual data is most easily handled in C++ with the type std::string. That is to say, objects of class "string", which is declared in the "std" namespace. You will need to #include the <string> header - this is NOT the same as <cstring> or <string.h>; those are backwards-compatibility headers for C-style code.

In C, you will have to rely on some hackery - it is well documented and gets supported reasonably well by library functions, but is still quite tricky. The basic idea* is that "char" - a numeric, one-byte type - is used to represent a single letter of text. Thus to represent text, one arranges to have a block of sequential char-typed values in memory somewhere, and then gets a pointer to them - a char *. To handle these properly requires quite a bit of background knowledge on pointers and memory allocation, unfortunately.

In the same way that literal numbers of type 'int' can be used in your code by just typing the number, you can use "string literals" by wrapping them in double-quotes. (There are special rules for dealing with string literals that have double-quote or other strange characters in them.) BUT beware! These are of type char*, not std::string - even in C++. Now, a std::string will be able to "deal with" a char*, but because char*'s are pointers, they don't work so nicely with each other. In particular, you can't "add" them (string them together) conveniently. The easiest solution here is to create a temporary string from one of them.

Quote:
 I know that "int" is for numbers. Next thing is that when i try to to divide to numbers i get answer "0", why? All other operations are giving normall answers.

"int" is for integer numbers. Operating on two integer values yields another integer; for division, this means the remainder gets thrown away. This "integer division" is actually very useful in a lot of game programming contexts, especially in combination with the modulo operator (represented by a % symbol), which produces the remainder for such a division.

To get a decimal result, you will need to use a floating-point type, such as "float" or "double". However, these have their own pitfalls.

* There are *many* simplifications here. Experienced programmers are encouraged to spot them all as an exercise.

// Sample (tested!) code to illustrate the ideas.#include <iostream> // for input and output#include <string> // for the std::string typeusing namespace std; // tells the compiler to look in the std namespace// for any identifiers (global variables, type names, etc.) that it can't// find definitions for in our own code.int main() {  // In C++, main() should return int, never void.  string message = "hi "; // we can initialize a string using a char*  message += "there!"; // adding char* to a string works too  3 + 4; // a computation on its own is valid, but won't "do anything" unless  // you store the result somewhere or otherwise cause a side effect (like  // outputting the result). I'm just doing this to show:  // "hi " + "there!"; <-- not valid! Both pointers; can't add them.  // Anyway, a good compiler will give you a warning for doing something like  // this (or can at least be configured to do so), but will still compile your  // code.  cout << message << endl; // output the message.  char x = 8;  int y = 3;  // Notice I declared y as a char type; this is to show that the individual  // "char"acters of a char* are actually numeric values - the console maps  // them into display characters via ASCII.  // Output the division as a fraction.  // We'll do this by showing the whole number part, then a space, then  // the remainder, then a slash, then the divisor.  cout << "8/3 = " << (x/y) << ' ' << (x%y) << '/' << y << endl;  // Note that *single* quotes produce a character literal, not a string  // literal. Thus it can only hold one byte, but it's not a pointer, it's  // an integral type - so you can do arithmetic with it. Now, to do  // *meaningful* arithmetic is the hard part ;) There's really only one  // trick you are likely to rely on there:  cout << static_cast<char>('0' + x) << endl;  // Here we sum '0' - which is 48, because of that encoding - and 8, to get 56  // - which is '8' as a printable character. The trick is that digits '0'   // through '9' are sequential in ASCII. However, to print the character '8'  // rather than the numeric value 56, we need to "cast" the result back to  // a char type - because summing the two chars actually gave us an int.  // To finish off, let's show the division as a floating-point value. We'll  // cast x to a floating-point type, in this case "double". Division between  // "mixed" types (one floating-point and one integral) gives a floating-point  // result, according to the rules of the language.  cout << "8/3 = " << (static_cast<double>(x) / y) << endl;}

##### Share on other sites
I'm suprised nobody said Code::Blocks. Its still beta, but its pretty good (though, I'm sticking with MVSC++ 6 for now.)

##### Share on other sites
Thanks Zahlman for explaining it to me.
I was reading some tutorials and now i understand a bit more of if statements, functions, structures,cases and loops.And also a little bit of pointers(Althought i don't see any use of it so far). What else should i learn to start making some basic game?
I also wanted to ask about graphical aspect of program. Everything i have so far wrote is running in dos-alike window. This reminds me programs written in pascal;).
Do i need to know other c++ commands or maybe graphic is totally seperate aspect?

BTW: Sorry for my english, i know that i often make mistakes but i'm trying to do my be

##### Share on other sites
I learned what they were and the basics of how they worked, then I forgot about 'em. I programmed happily until one day I needed to do something, and a pointer was perfect for it. Then I used a pointer. Now I see more and more things a pointer will work well for.

Don't try to push yourself too hard, and consider getting a beginner book. Books are nice because they (usually) start simple, build off their own material adding slowly until you have a basic understanding. Sure you could get the same information off the web, but it takes more time, it's not all the same writing style, and other sundry downfalls. Good luck.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627711
• Total Posts
2978753

• 21
• 14
• 12
• 39