niedziela, 14 lipca 2013

What I have learned from development of Super Heli Land so far?

While Super Heli Land is by no means complete, here is some bits I've learned from it so far.

Plan ahead and do it right
While I've planned engine out before actually write it which reduced WTFPCL (WTFs Per Code Line) greatly, I didn't do it right. You see, I've planned everything - how sprites, animations and world generation would work, heck I even made my-freaking-own design of State Machine since I didn't like other solutions. Unfortunately I didn't anticipate all things that I'd face while making engine. Because of this last few days I've spent on implementing GameObject base class, so I'll avoid mess I'd surely make if I'd try to use pure sprites for player character and other things.

Procedural generation isn't so hard
Seriously. Sometimes making few circles with random positions and radiuses can make entire cave system. Making ground and other objects on right positions isn't hard either and is pretty fun to implement! Of course 3D generation is probably another story...

Use source control from day one
While I didn't use it from start, now I'm regretting this. No, I didn't loose any stuff, but in case of big projects, late "initial commit" can weight several hundred of MB and it will upload slowly. Also, I cannot even start to imagine how I'd feel if there would be some sort of HDD failure before I've uploaded SHL to Github.

You should always make some debug game state to avoid "test stuff" all over the place
Yes, experimentation with code to find out what works best is important, but you should reserve some debug state for that. Because when you test stuff all over the place, sometimes you get leftovers from these tests which makes your game unstable with weird bugs.

At dark beginnings of Super Heli Land, when it wasn't Super Heli Land but instead Hello Allegro.pas program I've tested engine stuff like world generation, sprites, etc. directly in main code. That was bad, but then again it is my first game written without any game making program or "real" engine (while Allegro takes many things out of my head as developer, it is still just graphics/audio framework and not an engine) so it is also learning experience.

Coding is fun!
Seriously, even if you don't consider yourself a programmer, you should give it a go! Maybe you'll like it too?

czwartek, 20 czerwca 2013

GameDev is hard

...if you don't have proper tools.

If you decide to build your own engine from scratch using only barebone frameworks, like OpenGL, then yes, it IS hard. But in the advent of easy to use tools like Game Maker, Unity, Stencyl, Game Develop, etc. the only thing you REALLY wants to take care of is to make actual game content - models (or sprites if it's 2d game), music/sounds and levels.

Granted, this is like 90% of making actual game and maybe, just maybe I shouldn't be speaking about it since I didn't released proper game yet (The Art of Tiles and Adventure Cavern don't count as those aren't finished), but from what I've learned from my tries at this I can assure you that most of glitches comes from trying to reinvent the wheel rather than making actual content (where reinventing the wheel equals to trying to write your own collision detection algorithm, etc.).

Of course, you can't run away from coding, but when you have some foundation to build on - be it game engine like Unity or CraftStudio (last has that cool N64 bit to it - you should definitely check it out!) or framework that does most of heavy lifting for you (for 2D games, Allegro is my favorite, as well as Johan Peitz's, the very same person who made such hits like Happyland Adventures, Alex the Allegator 4 and Icy Tower so that's saying something), it isn't nearly as hard.

Also choice of programming language for your game matters too. Some languages like C#, Java and Pascal are very easy to pick up and modern compilers for those makes very efficient code which is well-suited for games (Minecraft is running on Java, Blockscape and Terraria on C# and Hedgewars, open source clone of Worms runs on Pascal - the only C/C++ parts are GUI code and Lua interpreter and it's only because Lazarus and pascal bindings for QT and Lua were in too early phase to be usable when project was started, whole engine stuff is written in Pascal).

Other languages, like C/C++ are in most cases an overkill for games unless you do some heavy rendering or do some expensive calculations.

Why? Because of thing I like to call Pointer Hell.

In most C/C++ APIs pointers are used like... everywhere, even in places where passing them to function/procedure by value instead of by reference (which is what pointers roughly do, to those of you who aren't coders) would be enough, one of best examples would be WinAPI MessageBox function:

int WINAPI MessageBox(
  _In_opt_  HWND hWnd,
  _In_opt_  LPCTSTR lpText,
  _In_opt_  LPCTSTR lpCaption,
  _In_      UINT uType

For those non-programmers around us, it LPCSTR, HWND and UINT are types. LPCSTR is, of course pointer to a string.

The hell? All this function does is to show message window, be it OK window, OK/Cancel or Abort/Retry/Ignore. Yet, it requires pointers to text to be displayed (which won't change there).

Then you deal with such "nice" things like memory leaks because you forgot to dereference some pointer somewhere, which are almost untraceable in larger projects.

That's what I'm calling Pointer Hell.

Of course pointers are nothing to be feared of and they have some serious applications like lists or tree-like structures. You should definitely make use of them, when they are needed.

Where "when they are needed" means "only if you can't do it with normal variables and passing parameters by value or such approach gives some serious lag".

Here it is place for my favorite quote about C/C++, by David Keppel:
C++ provides a remarkable facility for concealing the trivial details of a program - such as where its bugs are.
That is SO true.

I hope this little post has given you something to think about. Maybe some of you will change your tools to better ones - you can dig hole with a spoon, but isn't shovel much better?