Jump to content

  • Log In with Google      Sign In   
  • Create Account


We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Member Since 26 May 2008
Offline Last Active Jan 08 2012 06:15 AM

Posts I've Made

In Topic: [SDL] Efficient collision detection?

25 September 2011 - 02:55 PM

Like what KDMiller3 said, you should create a function that will tell you if there is nothing taking space in the location you want to move to. So like if(areaAvailabe(<where player wants to move>)) returns true then proceed to move the player there. Though it's mostly the reverse of what you're doing now.

In Topic: "Game" crashes when instantiating object

23 September 2011 - 09:35 PM

Alright, just checked again, and it actually does not work. Must of grown delirious when programming late at night and assumed it was fixed.

Anyway, File.c_str() doesn't work, but just putting in "./image.png" does, even though File.c_str() should equal the same thing. Since SDL stops you from outputting to the console I'm going to work on writing the strings to files like Ectara said.

OnLoad() (which is a part of CSurface) is declared as a static function. You put in a char array (or c-string as I think they're called) and then it returns a pointer to a surface. What's odd is that it seems to still return a not null value when it fails to load the surface.

EDIT: Ok, it's working again. I just made a stupid error that gave me some weird results. I'm pretty strung out right now though, so I'll work on what I want for awhile before I post another question here. Thanks again everyone.

In Topic: "Game" crashes when instantiating object

23 September 2011 - 02:21 PM

I edited the OP stating that I fixed it by using File.assign() instead of File=. Though I guess if you want to clarify:

std::string File

function(std::string n){File=n;}

The function is then called likeso:


Why would File=n not work yet File.assign(n) does?

In Topic: Multiple classes in the same .h and .cpp files

23 September 2011 - 02:42 AM

Because I don't like switching through .h and .cpp files, I just put the headers and the code in the .h file. How bad of a practice is this?

For example

class a








In Topic: "Game" crashes when instantiating object

22 September 2011 - 11:34 PM

Alright, I'm having another problem.

File is a std::string equal to "./image.png"

I use a function that takes a filename as a const char* and loads an image.

OnLoad(File.c_str()) fails to load the file

OnLoad("./image.png") works.

How do I convert File into a const char* that would work with this? (No I cannot change the function to take in a std::string instead)

Tell me if you need more information, I'm updating the OP to include code I believe is relevant.