
Open the demo:
http://www.steffest.com/boulderflash/ex3.html |
November 2007:
Some game logic has been added.
Most important: gravity: boulders, diamonds and emeralds fall down when not supported.
You can collect emeralds and diamonds (and dirt) but nothing else.
Some enemies are already there: bugs and tanks: they are dumb creatures that crawl the cave.
Don't worry about touching them ... for now: you can't die yet !
With some loop optimisation, Actionscript is capable of checking a standard 64x32 cave in 1 frame, so thats not bad.
Even a cave full of crawling bugs (that's 1800 moveing objects with a calculated behaviour) is no problem.
But ... the script delay is noticable allready ...the scrolling is not as smooth as the first example without game logic.
I think when I add all the missing Emerald Mine objects (like Yams, robots, magic walls, nuts, keys, doors, acid, amoeba) then the engine will be saturated.
This engine uses a 2 dimensional array to hold the leveldata. 1 dimensional arrays are usually much faster, so as comparison I changed the engine to use a 1 dimensional array.
Hmmm ... a tiny bit faster but hardly noticable. Plus, the code isn't that clear and readable anymore.
Speed optimization is a good thing, but not if it turns your code into un-reusable and incomprehensible garbage.
So: back to the 2 dimensional arrays.
Offcourse, nowadays we have Flash9 - with the much (MUCH!) faster Actionscript3, but that will be for another incarnation: Last week I got hold of Flash Lite 3 for mobile devices, which supports flash8/Actonscript 2 content. Yeah!!! Emerald Mines on my mobile phone!
This time, I'll stick to Flash 8, and settle for EMV4 compatibility.
Still: that is good enough - there are "only" about 30.000 emerald mines leves out there :-)
That brings me to the next step: Now is also the time to add a level-loading routine to the game, instead of rendering it randomly.
Emerald mines uses a binary levelformat, but with the current state of webstandards- it seems obvious to store the leveldata in XML.
Unfortunatly, there is no current boulderdash or emerald mine XML levelformat, but the "BoulderDash Common File Format" comes pretty close, so I'll adopt that one.
Next step is to add the missing game logic, most notably that you can actually get killed in those dangerous caves and that you can get to the exit after collecting enough diamonds, actually finnishing a game.
Then the missing Emerald mine objects, levelset loading, sound, scoring and timing ....
To observe the behaviour of the engine, some more examples:
- Stretching the movie takes away some resources, so a lower framerate, but more nostalgica!
- the engine running with visibla area of 640x480
- a cave with 1800 bugs to be calculated each frame.
- a big level with 16384 tiles (128x128): You clearly see the actionscripting sucking all the juice each frame: unplayable!
- the same 128x128 levelmap with the 1 dimensional array engine ... not faster
Sourcecode is available:
BoulderflashV3_CS3.zip
Flash CS3 is needed to open it, but if you don't have it: No worries! read on ...
And since this is turning into an Open Source project anyway, I have moved it to the excellent Open Source Flash compiler Mtasc .
This brilliant compiler lets you compile Actionscript 2 into swf files, so you don't need the Flash IDE anymore.
Currently I still use Flash CS3 to compile the bitmap into an swf, but I'll move that to the equally brilliant swfmill shortly, that lets your compile binary assets into swf from an XML file.
Add to that my favourite Actionscript editor, Flashdevelop (with build in Mtasc support) and you have the perfect free open source flash developers package.
Sourcecode to compile with Mtasc (no .fla needed here)
Boulderflashv3.zip
or if you're having trouble to get it to compile:
This is a version that includes Mtasc. Just hit compile.bat and you're done.
Boulderflashv3_mtask.zip
|