Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualCornstalks

Posted 21 February 2012 - 11:50 PM

Wow..smart pointers. Is it just me or is C++ a very dense language? There are so many ways to do everything and so many things to take advantage of. And I thought having "pointers" was strange, as opposed to having everything just being a normal variable. What's wrong with using just regular variables anyways?

Nothing is wrong with regular variables.  There are just certain things you can't do with them.  For example, say you want an array of integers somewhere, and you want to prompt the user how big this array should be.  You can't just create a normal variable on the stack that has an arbitrary length that you can change depending on what the user says.  You have to prompt the user how big the array should be, and then dynamically allocate that memory on the heap and access it through a pointer, which is exactly what std::vector does for you.

Also, another quick question. Right now, what I'm doing is putting the assets I'm using in the directory of all my source files, and in the bin/debug/ directory as well. But I imagine as the assets grow more and more, adding everything twice isn't the way everyone else does it. Or should I just keep having a copy of the assets in the bin/debug, and as well bin/release and my source directory?

Why are you putting them in multiple places?  So that when you run the program they're in the same folder as your executable so it can find the resources?  If so, you should change your IDEs settings so that the directory used when debugging is the directory in which your art assets are placed, and keep them in one place.

#1Cornstalks

Posted 21 February 2012 - 11:50 PM

Wow..smart pointers. Is it just me or is C++ a very dense language? There are so many ways to do everything and so many things to take advantage of. And I thought having "pointers" was strange, as opposed to having everything just being a normal variable. What's wrong with using just regular variables anyways?

Nothing is wrong with regular variables.  There are just certain things you can't do with them.  For example, say you want an array of integers somewhere, and you want to prompt the user how big this array should be.  You can't just create a normal variable on the stack that has an arbitrary length that you can change.  You have to prompt the user how big the array should be, and then dynamically allocate that memory on the heap and access it through a pointer.

Also, another quick question. Right now, what I'm doing is putting the assets I'm using in the directory of all my source files, and in the bin/debug/ directory as well. But I imagine as the assets grow more and more, adding everything twice isn't the way everyone else does it. Or should I just keep having a copy of the assets in the bin/debug, and as well bin/release and my source directory?

Why are you putting them in multiple places?  So that when you run the program they're in the same folder as your executable so it can find the resources?  If so, you should change your IDEs settings so that the directory used when debugging is the directory in which your art assets are placed, and keep them in one place.

PARTNERS