Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Jan 2003
Offline Last Active Nov 26 2014 01:37 AM

#5167333 Funniest line of code ever ?

Posted by on 17 July 2014 - 03:11 AM

I've seen things....:

return STATUS_ERROR;  //This returns the status error

Anyway, if i look at 5+ year old code of mine i still would laugh out loud many many times. ;)

#5103652 How to write a undertemined size array to a txt file?

Posted by on 23 October 2013 - 05:21 AM

This is just bad, bad code design. You should seriously consider a rework of your game structure.

It's pretty pointless to store anything in a "i dont know exactly how many items i need to store" matter.


Sure, the example code above will work, even if you'd need a variable which has the number of elements to read, also stored in your file.

If you really want to continue with your approach, check out the previously mentioned JSON format, even XML will do. 


If you continue in that hackish way, you'll be very frustraed at some point and you'll end up throwing your project away.

#5097221 Component based system

Posted by on 27 September 2013 - 06:50 AM

I found this one pretty well designed:




best regards

#5089147 Windows.h has just dissappeared!?

Posted by on 26 August 2013 - 05:27 AM

Hasnt all of this been moved into the Windows SDK?



Search for it, either Windows 7 or Windows 8 SDK's available.

download and install it, maybe it's something like that.


best regards

#5013427 Using a pointer to point to a new object every frame

Posted by on 22 December 2012 - 09:37 AM

There's much much more wrong in that piece of code than just a plain pointer issue.


Besides the allocations you do every frame, there are also a lot more copy-constructor calls than you might expect.

Get rid of that; it may be just a Vec2 class but clean code doesnt hurt anyone.  use const references, or just pass the position as 2 parameters.


Next point is ... why do you want to use a pointer anyway? Sprite classes usually store their position for collision detection or rendering or whatever.

And you do realize that pointers take up memory as well, right?  Depending on the OS, the size is different. On Windows it's 4 byte if i remember correctly.

So basically you win nothing using your method.


best regards

#5003423 Using Constants in Headers

Posted by on 23 November 2012 - 02:55 AM

First of all, in your Constants.cpp file you need to write "const int MAX_INTS = 1000; "
The extern keyword means "declare without defining". In other words, it is a way to explicitly declare a variable, or to force a declaration without a definition.

The practice itself (putting the initialization into the cpp file) is a matter of personal taste. I personally like it because if i need to change the value for whatever reason, not every single file which includes the header file is compiled again.

But i wouldnt use "extern" anymore....i like static const uint32 MAX_INTS; in a header file more. ;-)