Jump to content

  • Log In with Google      Sign In   
  • Create Account

Do we use pointers in game programming?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 LiziPizi   Members   -  Reputation: 77

Like
0Likes
Like

Posted 25 April 2014 - 05:01 PM

I'm learning c++ from basic and I have reach the pointers subject.

should I skip it or learn it, its alot of stuff to learn about, do I realy need to spend time on it?

Is it gonna help me to program games? 



Sponsor:

#2 SeraphLance   Members   -  Reputation: 1421

Like
15Likes
Like

Posted 25 April 2014 - 05:07 PM

From a learning perspective, pointers are absolutely vital for dynamically allocated memory.  There are newer alternatives to regular pointers, but they all more or less work the same way.



#3 SeanMiddleditch   Members   -  Reputation: 6129

Like
9Likes
Like

Posted 25 April 2014 - 05:11 PM

I'm learning c++ from basic and I have reach the pointers subject.
should I skip it or learn it, its alot of stuff to learn about, do I realy need to spend time on it?
Is it gonna help me to program games?


In many ways, pointers are the only reason we even use C++ in the first place. Modern usage of C++ will certainly insulate you from most of the worst parts of pointers, but understanding what they are, how they work, why they exist, and when to use them is essential.

#4 ApochPiQ   Moderators   -  Reputation: 15833

Like
22Likes
Like

Posted 25 April 2014 - 05:11 PM

If you're wanting to learn C++, pointers are a critical tool - for almost any kind of software you want to write. Definitely don't skimp on learning them.

 

It also sounds like you're in a bit of a hurry. Motivation is great, but it's also important to understand that you're in for a very long and often difficult ride. The more things you are willing to spend time on learning, the better a programmer you will become over time.



#5 LiziPizi   Members   -  Reputation: 77

Like
1Likes
Like

Posted 25 April 2014 - 05:12 PM

From a learning perspective, pointers are absolutely vital for dynamically allocated memory.  There are newer alternatives to regular pointers, but they all more or less work the same way.

Thank you.



#6 achild   Crossbones+   -  Reputation: 1894

Like
2Likes
Like

Posted 25 April 2014 - 05:56 PM

More importantly than learning about pointers themselves, IMHO, is that learning them is a great first step to learning about memory. This will be invaluable later on as you gain more experience, especially when it comes to optimization (whether for speed or other types of targets).



#7 kburkhart84   Members   -  Reputation: 1663

Like
1Likes
Like

Posted 25 April 2014 - 09:39 PM

I concur with the above posters.  If you were interested in game development only, than you could use a tool very specific to it, like Unity, Gamemaker, etc...  But, since you are going the C++ route, which in my opinion has nothing wrong with it(except that it can take longer both learning and using, but with more control over code), I'd say you need pointers very much.  Technically, you use a form of a pointer any time you would dynamically create an object, and in games, you tend to dynamically create lots of objects, like enemies, bullets, etc...  Now, there are technically alternatives, but in any case, you should indeed learn the theory and then if you don't use them later, OK.  Then, if you need them in order to apply some API, you'll know what you are doing.  Even the "simple" Irrlicht engine uses pointers all over the place.





#8 Hodgman   Moderators   -  Reputation: 30441

Like
6Likes
Like

Posted 25 April 2014 - 10:02 PM

Pointers are vital in other languages too, but they're usually called something else, such as 'references'.



#9 ikarth   Members   -  Reputation: 430

Like
0Likes
Like

Posted 25 April 2014 - 10:41 PM

Pointers are vital in other languages too, but they're usually called something else, such as 'references'.

Caveat: many of those languages do not let you do raw pointer arithmetic, casting voids, or other dangerous tricks that you can do with real C/C++ pointers. But understanding pointers and memory is vital for a deeper understanding of computing, if you are looking for that.



#10 SeraphLance   Members   -  Reputation: 1421

Like
1Likes
Like

Posted 25 April 2014 - 10:43 PM

Pointers are vital in other languages too, but they're usually called something else, such as 'references'.

 

There's a big difference between pointers and references from a "learning" point of view.  References are "magic", so they're much easier to understand (or rather, not understand).  I don't necessarily think that's healthy, but you don't really need to understand how pointers work, or even memory at all for that matter, in a lot of higher level languages.



#11 Servant of the Lord   Crossbones+   -  Reputation: 19689

Like
9Likes
Like

Posted 26 April 2014 - 12:54 AM

Pointers are used heavily in game development - definitely a foundational part of C++ and a "must-know".

 

Many beginners have trouble learning pointers, so if you don't understand them, ask on the forums for better explanations. I personally feel most of the difficulty surrounding pointers is just because of the poor (in my opinion) way most books teach them.


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#12 frob   Moderators   -  Reputation: 21493

Like
9Likes
Like

Posted 26 April 2014 - 01:33 AM

I personally feel most of the difficulty surrounding pointers is just because of the poor (in my opinion) way most books teach them.

Agreed. A pointer is similar to physical-world concepts like a physical address. It is where a thing is. Some things are big and take up more space; a building gets a single address "123 Somewhere St", and the next building might be several slots away "147 Somewhere Street". It works less well in places where road numbers arbitrarily start at 1 on every street, but for cities based around "main street and center street" patterns the analogy holds very well.

I have read many descriptions of pointers and even though I know the topic well, I come away asking,"What did I just read?'
Check out my personal indie blog at bryanwagstaff.com.

#13 jbadams   Senior Staff   -  Reputation: 18749

Like
5Likes
Like

Posted 26 April 2014 - 11:28 PM

I personally feel most of the difficulty surrounding pointers is just because of the poor (in my opinion) way most books teach them.

 

I have read many descriptions of pointers and even though I know the topic well, I come away asking,"What did I just read?'

Sounds like a possible article topic for one or both of you if you think you could tackle it better! wink.png cool.png



#14 georger.araujo   Members   -  Reputation: 818

Like
0Likes
Like

Posted 27 April 2014 - 11:47 PM

I'm learning c++ from basic and I have reach the pointers subject.

should I skip it or learn it, its alot of stuff to learn about, do I realy need to spend time on it?

Is it gonna help me to program games? 

 

Learn it. The most basic SDL example uses pointers. GDNet's own article where a basic Snake game is described (made with SDL) uses (NEEDS) pointers, too.

 

Yes, it will help you (actually, it will ENABLE you to) program games. In C++, pointers are a necessity for passing by reference rather than by value, callback functions, and dynamic memory allocation. Even if you use a library that uses references rather than pointers where possible, like SFML, you need to know that a reference is a constant pointer that can't be null and is dereferenced automatically.

 

Some (pardon the pun) pointers to articles I like:

Ted Jensen's Tutorial on Pointers and Arrays in C

The Function Pointer Tutorials






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS