For an entire week I've been working on a canvas/html5 project of mine: the Kiflea Engine. "What's that?", you ask? It stands for "Kipdola's Flat Earth" Engine. It's a tiled based engine on which you can build a game. Or at least: that's the goal of the project. I'm not there yet, even though I feel like I've already made huge advancements.
The maps are built using Tiled. Any tileset you load in there will load in the engine. The HUD is built using a simple JSON file, ... As you can see in the image above, I've just finished my pathfinding algorithm.
If you want to try the engine in its current state out, you can do so here.If you would like to download the source, I've set up an SVN repository over here: http://kipdola.be/trac/repos/ You can download the code by executing this SVN command: svn co http://kipdola.be/svn/kiflea/
What does it do? It takes an array (or hash or object) and prints out every key with its value. If it comes along another array, it does the same thing again. It's such a useful feature in PHP, it's a great debugger-friend.
There are a few code snippets out there that do the same job, but I thought this one was quite small and compact. Don't forget to wrap it in a <pre> tag to get a nice layout./** * Function : dump() * Arguments: The data - array,hash(associative array),object * The level - OPTIONAL * Returns : The textual representation of the array. * This function was inspired by the print_r function of PHP. * This will accept some data as the argument and return a * text that will be a more readable version of the * array/hash/object that is given. * Docs: http://www.openjs.com/scripts/others/dump_function_php_print_r.php */ function dump(arr,level) else } } else return dumped_text; }
Ofcourse, this game also has to respond to the keyboard. I got tired of looking up keycodes real quick and decided to just create an associative array out of them, for the hell of it. My IDE even autocompletes them. Here's the list:// A var storing all useful keys for easy access var key =
Now you can use things like "key.Uparrow" in your code in stead of it's corresponding number. For example:// Bind the onKeyDown function to the onkeydown event. window.onkeydown = onKeyDown; /** *This function is called whenever a key is pressed on the keyboard *@param key The key */ function onKeyDown(keypress) }