Game Programming Tutorial series

A forum to store posts deemed exceptionally wise and useful
Post Reply
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Game Programming Tutorial series

Post by Buck1000 »

Hey guys, I've started a series of tutorials on game programming aimed at the complete beginner. So far, I have Part 0 done (took a long time to write!), and I will be working on the rest regularly. I'm trying to write the tutorials that I was looking for when I first ventured into the world of programming. The whole "learn by using" thing - I won't even touch classes until my second set of tutorials, since I didn't need them for my first few games.

So, if you want to learn game programming from the ground up, check out my series. You'll learn why classes are useful, by seeing what it's like without them =]

Comments and critiques would be great! =D

Check it out - http://codingb.blogspot.com/
Last edited by Buck1000 on Sat Sep 10, 2011 7:53 am, edited 1 time in total.
pc0de
Posts: 300
Joined: Wed Dec 05, 2007 4:41 pm

Re: Game Programming Tutorial series

Post by pc0de »

Applaud your effort. Beginners will likely wonder why the variable example snippet won't compile:

Code: Select all

int a = "4"; //Let's assign a value to a
int b = "772456"; //And to b
int c = a + b; //You can assign a variable the result of an operation, the return value of a function, and more
float d = a / b; //Since a/b in this case is not an integer, we need a float
 
cout<<"a / b = "<<d; //Display it! =D 
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Re: Game Programming Tutorial series

Post by shadowslair »

Yeah, you`ll better remove those quotation marks. Plus the line float d = a / b; looks a bit ugly and will throw a warning. You can also change it to multiplication and keep the type (int m = a * b;), work with floats or avoid this type of 'casting' etc. And for the tutorial you need to keep things simple, so you`ll better change the a to 10 and b to say 2. This way the reader could easily guess the result and compare it with the one, generated by the code and convince himself the computer can calculate such a thing correctly.

Looking forward for the next tutorial. :)
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Game Programming Tutorial series

Post by mongoose7 »

Code: Select all

float d = a/b;
serves no useful function. "a/b" *is* an integer. If you want to invoke the promotion rules you need something like

Code: Select all

float d = (float) a/b;
This will cast 'a' to a float and promote 'b' to a float, returning a float result.
Buck1000
Posts: 93
Joined: Sun Dec 14, 2008 8:02 pm
Location: Seattle, WA

Re: Game Programming Tutorial series

Post by Buck1000 »

Applaud your effort. Beginners will likely wonder why the variable example snippet won't compile:
Yeah, you`ll better remove those quotation marks.
Thanks for catching that, I didn't notice the quotation marks. Fixed =]
Plus the line float d = a / b; looks a bit ugly and will throw a warning. You can also change it to multiplication and keep the type (int m = a * b;)
serves no useful function. "a/b" *is* an integer. If you want to invoke the promotion rules you need something like ...
I didn't know operations had to be cast as well - the line doesn't throw a warning (at least not when compiling with "g++ test.cpp -o test"), but it does churn out an integer. Thanks for letting me know. I'll change it to an example of multiplication, and make a separate set of operations involving floats (and make the numbers smaller and rounder :wink: ). Casting is too complicated of a thing to teach in Part 0.
Looking forward for the next tutorial. :)
I'll go ahead and get started then =] It won't be done for at least a day though. I really underestimated how much there was to write in the first one when I got started. But, it's fun in its own way.

Gah, there's a mistake in my first post. *fixed
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Game Programming Tutorial series

Post by hybrid »

Always compile with -Wall under gcc/g++, then you will easily catch these errors.
Post Reply