Jump to content

  • Log In with Google      Sign In   
  • Create Account

Adventures in Programming: The Second Update

Posted by Night Lone, in Adventures in Programming 04 September 2014 · 471 views

Programming C++ Floating Point
So, I said I'd discuss problems and other things here gamedev related; so lets get started!

The biggest problem with game development, for newbies, in my opinion (could be wrong) is looking at the whole picture, think, "This is easy!" then do a few weeks work, learn that it's not as easy as was once thought of, and now all motivation is lost and you're thinking, "This is hard and sucks, and boring!" (okay, maybe not exactly that)

Well, the truth is, if you're always looking at the bigger picture, and you start doing the work, and you find out how big that picture really is, it'll always look like a giant. My suggestion is this:
1) Set realistic goals!

Don't say "I'm going to make a game engine in a week"...or a month...heck, don't even say a year, even though a year is possible. Why? For starters, "game engine" is very ambiguous, what features will the engine has? what language? whats the goal for the engine? and, most importantly, WHY are you making an engine?!

1.a) Set small realistic goals!

While this is basically the same as 1), I must reinforce "small" your end goal might be big, it might be huge, it might even be impossible, but if you take it one step at a time with small realistic goals, sometimes the impossible may be possible....you might die of old age when it's done...but that's another problem.

2) Don't move too fast!

I know, you just want to write code, and make a beautiful piece of art. But, if you move too fast, and try to learn too many things at once, you will over do it, and end up going slower than you planned. Also, another reason to take it slow is this: you'll find more bugs faster if you take it slow and think about your code before you code it.

3) Never slap a hack in your code!!

Sure, a hack can be fast and do the job; but the thing is, will it do the job well? Most hacks you'll put in code will cost you time later because you'll use that function with that hack, in an unexpected way, or someone else will, and boom, bug ville! Now you have to spend time and resources to find and fix that bug. Sure, it's your hack, and you know how to deal with it, so you write your code around that hack and you know it's limits. Someone else doesn't though. Also, while I'm at it, you may use a function, which uses another function, which ... uses that hack in an unexpected way, and boom, bug... and what's worse? Debugging it, removing that hack, and correcting your code and possibly correcting other code which works around the hack, takes time, and a lot of it!


Hack = more unexpected bugs = unreliable code = fixing the bug/hack = writing the code correctly = time for each step

So, just skip the hack - fixing the hack part, and just write the code correctly in the first place!

4) When using floats and variables, 1.0f doesn't always mean 1.0f; It's better to have a margin for error, computer floating-point error Posted Image
5) Don't be afraid to ask questions.

So what you might be a noob, we all were at some point.

6) And, above all else: “Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - Martin Golding

And yes, I had some floating point problems with my engine, forgot to make room for "floating point rounding errors" Pain in de Arse!

News about my engine:
For those who don't follow my Twitter (you really should, @nightlonegamer), I have Textures all done, got a few new classes to the 'family', GUI, GUIElement, GUIImage, and GUIButton. While I'm trying to stay independent from SDL2, so for those who may end up using my engine, they could, theoretically, rip out SDL2 and use Win32 or whatever they wish, it may end up difficult for me to not use SDL2 stuff here and there, I am trying to keep it nice and separate though.
Also, I'm gonna probably start doing some major reorganising of a few things, mainly refactoring and adding classes that need to be added. Going to work on my Blender exporter so that my engine can load my custom format*. Also, if I haven't said it in the last post, PNG files are now supported, and so is texturing, just need to fix my exporter to support the new things I've added! Right now I'm ignoring lighting, I really shouldn't, but I want a full exporter before I start playing around with that stuff...I can smell a game cooking up!! That or it's my brain frying...

*Little word of advice: Custom formats are good, only IF you're going to use them properly; also, they are a pain to make and implement, so, if you want to support your own format, go ahead, but I do recommend downloading a library that loads formats for you.

Anyhow, Enjoy your time! And I'm thinking of doing these every Wednesday night (or early Thursday, depends on your timezone). Program, and program well!

May the Code be with you....(sorry, star wars music is playing in the background xD)