So many things keep me from making games

Started by
13 comments, last by apollodude217 17 years, 2 months ago
I love video games. I also love programming. So, I decided to try getting into game development. I'm mostly a C# person, but since there aren't many 3D tools available for C#, I learned C++. I get mostly all of it, except... pointers. I hate pointers so much. I've read that pointers are the parts people have the most trouble with when they are learning C++. I bought a book called "C++ for Dummies". It's really good, but I've read the pointers chapter almost three times and I still don't get the point of pointers. (heh heh) I know they point to other variables in memory, but in some programs, I see this:
SomeClass* var = new SomeClass();
I don't get it. If "var" is only just being created, why does it need to point to anything if it's the only instance so far? My second problem is that I have absolutely no money. I don't have a problem finding free tools, I have a problem finding people who just make stuff to make stuff. I'm no good with graphics, so some one else has to do it. But, I can't pay them. Basically, any tips you have would be a big help. Thanks.
Advertisement
If your a C# person you should DEFINATLY get started with C# and XNA... The XNA framework will make things a lot easier for you without taking away your freedom of making whatever you want. I've also started Game programming recently and I have to say, I'm glad I started with XNA... C++ can get VERY confusing if you dont know much about game programming.

AND I was a C++ person and knew nothing really about C#, and I still find XNA easier. So it should be much easier for you.
What you alluded to in pointers is called dynamic memory allocation, where a block of memory is allocated for use during runtime. When using dynamic memory like this, the only way to access that memory is through the initiated pointer. Pointers don't need to point to anything right away, but you can't use them until they point somewhere.

Dynamic memory, as far as I've been told, is a niche subject. Pointers are wonderful when dealing with classes, in particular virtual functions and abstract base classes, and other data structures of that sort. If you're having problems with them, practice using pointers to mess with integer variables and get a feel for how they work. Most pointer tutorials are a little more advanced than that, in that they expect you to understand the syntax fully.
I would like to switch to XNA for the next project as well. However there are many powerful engines and libraries developed for c++, such as the excellent Torque Network Library. These things take years to develop so the best things will remain c++ for quite a while.

To answer the pointer question, "SomeClass* var" creates the variable "var", which can store a pointer to an instance of SomeClass. The variable declaration allocates memory (4 bytes) for the pointer itself, but does not create the c++ object. "new SomeClass()" is the statement which does just that and returns a pointer to the newly created object. That pointer value is then assigned to "var".

Always think of a pointer as an *address*, like a house number, then everything makes more sense.
Quote:Original post by darkcypher543
I'm mostly a C# person, but since there aren't many 3D tools available for C#, I learned C++. I get mostly all of it, except... pointers. I hate pointers so much. I've read that pointers are the parts people have the most trouble with when they are learning C++.

I don't get it. C# uses pointers constantly. Every single variable with a class type is a pointer. The only differences are pointer arithmetic (which you don't use much in C++) and the fact that you have to delete things when you're done with them. If you're a C# person, don't you already know pointers?
Quote:Original post by Sneftel
Quote:Original post by darkcypher543
I'm mostly a C# person, but since there aren't many 3D tools available for C#, I learned C++. I get mostly all of it, except... pointers. I hate pointers so much. I've read that pointers are the parts people have the most trouble with when they are learning C++.

I don't get it. C# uses pointers constantly. Every single variable with a class type is a pointer. The only differences are pointer arithmetic (which you don't use much in C++) and the fact that you have to delete things when you're done with them. If you're a C# person, don't you already know pointers?


C# does not have value types for objects. So people equate the object instance with the reference variable that points to it. But yeah,

SomeClass * var = new SomeClass() in c++

means pretty much the same as

SomeClass var = new SomeClass() in c#
Quote:If you're a C# person, don't you already know pointers?

In C#, declaring as class (as goldenpanda showed) is simply:
SomeClass var = new SomeClass();

C++ is:
SomeClass* var = new SomeClass();

In most C++ programs I have seen, the "*" is not always used, which is what confuses me. In C#, I can simply leave the "*" off and it just works. I don't have to understand pointers and how to apply them, because it's all done for me.

I think I'll try using XNA again. It seems more popular now than when I last tried it.

Does anyone have any suggestions for making a game with no money?
Quote:Original post by darkcypher543
SomeClass* var = new SomeClass();


There are three things happening in that statement:

SomeClass* var


This part is declaring a variable called 'var.' It is of type 'SomeClass*' which means it will contains the memory addresses of SomeClass objects. It does not create any SomeClass objects, or indeed change anything other than declaring some space to store a memory address in.

new SomeClass()


This part is creating a new, nameless SomeClass object in memory somewhere, and then evaluating to the address of it. It is entirely independent of the rest of the statement - it's a self-contained expression that can be evaluated on its own.

=


This part is storing the address that the 'new SomeClass()' expression evaluated to in the 'var' variable.

Why are pointers and the objects they point to created separately like that? Well, maybe you don't have an object to point to yet, or maybe you'll want the pointer to point at an existing object instead of a new one. By decoupling the two, we can have one object pointed to by many pointers, or one pointer that, over its lifetime, points to many objects. If the two were tightly bound, we'd be stuck with one pointer per object, and that would make a lot of things very difficult.

Quote:My second problem is that I have absolutely no money. I don't have a problem finding free tools, I have a problem finding people who just make stuff to make stuff. I'm no good with graphics, so some one else has to do it. But, I can't pay them.
Make placeholder graphics for now - stickmen, etc. Just make temporary pieces to get your game working. Once you can show off a working prototype, you'll find it easier to persuade people to help you out. Never be prevented from working on some code just because you don't have the asset for it.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Correct me if I'm wrong, but I believe that:

SomeClass* var = new SomeClass();


and

SomeClass var = new SomeClass();


are actually doing the same thing. Because the variable "var" is actually pointing to the address of the object ( of SomeClass ) in the heap. It's just that in C++, you need to specifically state that your variable is a pointer-to-address. In C#, you appear to be assigning a variable to an object, but what is actually happening is that you're assigning the variable to the *address* of that object.

Java programmers would also be familiar with this.
Quote:Original post by superpig
Quote:Original post by darkcypher543
My second problem is that I have absolutely no money. I don't have a problem finding free tools, I have a problem finding people who just make stuff to make stuff. I'm no good with graphics, so some one else has to do it. But, I can't pay them.
Make placeholder graphics for now - stickmen, etc. Just make temporary pieces to get your game working. Once you can show off a working prototype, you'll find it easier to persuade people to help you out. Never be prevented from working on some code just because you don't have the asset for it.
This is exactly the strategy I'm taking. I've spoken to one artist, and he said that he had done work for games before, only to have the game never made and his work put to no use. So I'm going to have a good, solid beta before I ask for graphics and sounds. Go for the simple .bmps and .wavs of scalp-scratching or whatever in the meantime.
Justin RioGame-maker/player hobby

This topic is closed to new replies.

Advertisement