Sunday, November 14, 2010

Life and Junk

Lately, as I'm sure a lot of you noticed, I haven't been in the mood to post or program or anything of the like. But, occasionally I get the urge to start doing stuff like programming again.

It's the main reason my game has taken so long. Even though I have been working on the game for about two years, I have only been actually working for about a total of two months.

On an unrelated note, have you ever just wanted to quit your job, take all your stuff, and just leave. Like to another part of the country. Well, I have. A lot actually. But usually it only lasts for about five seconds, then I come back to my senses and realize how stupid that would be.

Anyway, till next time, Have Fun.

Saturday, November 13, 2010

iPod touch

I got a new iPod touch 4g a few days ago and found a few apps that make blogging a lot more convenient so I will probably (hopefully) be posting more. And seeing how my last post was about a month ago, that's a good thing I think.

So, after years of bashing apple without ever having owned anything from them, I now have a reason to hate and, to a lesser extent, like them. First, on the iPod, for the most part it is awesome although the auto-correct feature is sometimes annoying. The only bad part so far is iTunes.

For example, if you download an app then decide your in a hurry and don't want to copy the app to your computer during the sync, iTunes decides you must not like it and uninstalls it from the iPod.

Hopefully, with any luck my mood won't change and I'll make a real post tonight after work.

Sunday, September 26, 2010

Im Still Alive

I've been playing Halo: Reach so much recently that I have't been able to post much here or work on my game. But, here is a status update for those that care:

I have the graphics and control systems loading properly and actually displaying something and hope to have some screen shots soon of what it can do.

I am currently working on the loading and saving of game worlds for both client and server.

That's all I got done last night, as that's the only time I've been able to work on it now that Halo has finally started getting old.

Saturday, September 18, 2010

Halo Reach

Today I'm going to take a break from programming to review "Halo: Reach".

  In campaign mode, Halo Reach is fast paced, engaging, and fun. The story line is one of the best every seen on a Halo game, and the best there ever will be, since Bungie is no longer going to make them. The characters feel real, and you form real emotional connections to them.

  In multiplayer, the fun gets even better. Bungie went all out in this iteration of the game. Every game type you could want, up to 16 player matches, and an impressive lineup of maps. And, now, matchmaking in both campaign (Bungie has temporarily locked it to prevent "spoilers") and firefight modes.

 Bungie has redesigned the graphics engine for Halo Reach from the ground up to allow them to not only have AA, but also to have huge maps that span miles of terrain. The cutscenes look spectacular in particular and are rendered in the game engine so in co-op you see the player that did the best in the last round as "number 6". But dont worry that your XBox cant handle the AA, because the engine will turn it off if it needs to, in order to maintain a good frame rate.

 The new control scheme takes a little getting used to if you didn't use "bumper jumper" in Halo3, but all the classic configurations are available if you don't like the new one. But, no matter which you pick, the controls never feel clunky and there is always a setting that will be comfortable to you.

Overall: 10 out of 10.

Sunday, September 12, 2010

Once again ... C/C++

Today I am going to talk about C++ instead of basic C. C++ adds several new ideas to C, the biggest of which is Object Oriented Programming. Objects are variables (called classes) that contain other variables and/or functions (called members). There are two ways to create an Object: class and struct

Typically, a class contains both variables and functions and a struct contains only variables, though in newer versions of C++ the two are treated the same. Lets create a struct:
struct Account
   int Number;
   float Balance;
Notice the semicolon " ; " after the ending bracket is required. To access the two variables I created, I would, first, create a variable of type "Account" then you can access the members of the class with the period operator " . ". Like this:
Account anAcct;
anAcct.Number = 123567;
anAcct.Balance = 0.0f; //"f" tells the compiler it is a float type. use "c" for char.

When you create a class, you can specify a "constructor" and a "destructor" that are automatically processed when the variable is created and destroyed respectively. Both are named the same as the class with no type defined though the destructor has a tilde " ~ " before its name. For instance:
class Account
   int Number;
   float Balance;
      Number = 0;
      Balance = 0.0f;

   void SetBal(float B)
      Balance = B;

To access the functions inside a class is the same as accessing a variable. I.E. I could call "anAcct.SetBal(1300.45f);". If you were to create a pointer to an "Account" object, you could access the members with the "arrow" operator " -> ". Anything referenced in such a way is treated as the real object and not a pointer. For Instance:
Account anAccount;
Account *pAcct;
pAcct = &AnAccount;
pAcct->Number = 9023;

Inside a class you can even tell the compiler how to handle operators (such as +, -, =, ==, etc.) using the operator keyword.

I've included two files to show the operator keyword in use:
DataTypes.h - the file that defines the classes.
DataTypes.cpp - the file that has the actual code.

And, finally for today, for an object to create a pointer to itself, it can use the keyword this.

C/C++ Part 3 - the sequeling

Last time I talked about Arrays and Loops. Next I need to mention conditional statements. The most common conditional is the if/else statement. The simplest way to show you how to use an if statement is to show you.

int x = 1;
  //Stuff goes here if true
} else {
  //Stuff goes here if false

Fairly strait forward. If the condition is true then the first block is processed. If it is not, and you have supplied an else, then the else is processed.

Up until now, as most have commented, C is similar to many newer languages like JavaScript. That is mostly due to the fact that they are based off of C. Now, I will talk about some features that separate it from the rest.

Pointers, for instance, are powerful and fairly easy to use. Pointers contain only the memory address of a variable. Creating a pointer is easy. Simply add an asterisk " * " in between the variable type, and its name. White space is not needed as the asterisk is a special character that cannot be part of a variable name. To create a pointer to an int:
int* Pntr1;
int *Pntr2;
int * Pntr3;

All three are correct. To "point" a pointer to a variable you simply need to use the ampersand " & " character before the name of the variable. Such as:
int Acct;
int* pAcct = &Acct;

And, finally, to treat the pointer as if it were the original variable, use the asterisk again before the pointer name. For instance:
int Acct;
int* pAcct = &Acct;
*pAcct = 5;

In this example Acct will be set to 5 and the pointer will remain unchanged. In C the most common use of pointers if for whats called a "C-Style String" which is simply a pointer of the type "char". Strings, of any type, are able to store lines of text as an array of chars terminated by a " \0 " (a special character with a value of 0).

To use strings, and other special types, you will next need to know about the #include statement. #include is a pre-processor directive meaning that it is processed during the compile process (when the compiler turns the code into a program). Pre-processor commands are all independent of the program you are making and, in fact, will not be part of the final product. There are only a few commands and the ones you will most need are:

#include - includes a file.
#define - creates a pre-processor variable used both in #if statements and in the C code
#if - operates mostly the same as a normal if statement
#ifdef - if a pre-processor variable is defined, then the following code will be compiled.
#ifndef - if a pre-processor variable is NOT defined, then the following code will be compiled.
#else - if the last #if command was false then this code is used instead.
#elif - same as an #else except it also includes its own condition.
#endif - ends an #if statement's reach.

The rest can be found here as well as some other interesting info. I am not going to go into detail about C include files but most of them can be found here.

Next time I am going to talk about C++ which adds many new things.

Saturday, September 11, 2010

C/C++ Continued

If you haven't read it yet, my first C tutorial should be read first by beginners. Last time, I talked about some basics of C. This time, I will talk about some more slightly advanced topics.

Lets say, you wanted to store one hundred account numbers in your program. To do this with normal means would mean typing out:
int Acct1, Acct2, Acct3, Acct4; //And so on ...
// Yes, you can define more than one variable at a time.
Needless to say, this would take a long time and you would have to reference them all separately. This is the reason we have arrays. An array simply is a simple way to store a lot of data within only one variable. To create an array holding 100 int variables, you would simply do this:
int Accounts[100];
Then to call a position in the array you would do this:
Accounts[0] = 2884756;
Arrays will always start at 0 and end one position less than the number you typed originally. In this case I typed 100 so the array indexes are from 0 to 99.

Since you can call a position on an array with a number, you can simply insert a variable holding a whole number inside of the brackets " [ ] ". (char, int, short, or long) This allows for much more versatility than having to specify each time which variable you wanted in your code. For instance, Lets say I wanted each number in the array to be set to 0. You could do the following:
int Accounts[100], x;
for(int x=0; x<100; ++x) // I'll talk about this in a minute.
    Accounts[x] = 0;
Or to make it simpler, when you create an array you can set a default value by using the curly brackets "{ } " around a value. Like this:
int Accounts[100] = {0};
You can also set all values by separating with a comma like this:
int Abc[3] = {1,2,3};

Now, in the last example I used a new command called for. for is one of the loop types available in C (as well as many other languages). for takes 3 parameters broken down into 3 steps: Initialization, Condition, and Increment.

Initialization is processed only once before the loop starts. (In the example, creating a integer variable "x".)
Condition is checked every time the end of the loop is reached. (In the example if x is less than 100.) If Condition is true, the loop repeats. If it is false then it doesn't (or breaks).
And, finally, Increment is processed every time the loop repeats. (In the example "++" causes the variable x to increase by 1. It is the same as typing "x=x+1")

Other types of loops are:
do while - 1 parameter; Condition. The do while loop always processes the first time regardless of the Condition statement. Use:
do {
   //Stuff goes here.

while - 1 parameter; Condition. Use:
while(x<100) {
   //Stuff goes here.

In all of these, the condition statement must return either true or false. This, in C as well as other languages is called a "Boolean" statement. To get this you need one of the Boolean operators:
== (equal)
!= (not equal to)
< (less than)
> (greater than)
<= (less than or equal to)
>= (greater than or equal to)