Terrain

Today I thought I’d have a play with procedural terrain creation. I found a relatively straightforward javascript implementation, so thought I’d have a go porting it over to Haxe.

This, of course, is vastly more complex than anything I’ve done before.

In theory, it’ll end up looking something like this:

terrain-result

What I have so far looks like this:

screenshot_terrain_1

Oh, and also drags the entire machine to a grinding halt. ¬†One key issue – much as the same problem I had with Fly Lines, I haven’t yet figured out (how/if) I can¬†control the screen refresh. If I’m showing a static image, I REALLY don’t need to be trying to refresh that 60x a second. Particularly if the creation of that static image a) doesn’t change much, and/or b) was computationally complex to create.

*cough* I may have bitten off a little more than I can chew here.

Moving slightly forward. Things now look like this:

screenshot_terrain_2

Which still looks like bollocks. More concerning is that it drives my machine into the dirt, and takes about 5 seconds to render. Ie, even if I get it sorted completely, it’s still going to be utterly unusable. Which is a real shame.

Hmm, closer. And re-rendering every couple of seconds:

screenshot_terrain_3

 

This is getting weirder. This is now super fast (updating multiple times a second), but I have no idea why it looks like this:

screenshot_terrain_4

 

Still SO many questions with this piece of code:

screenshot_terrain_5

What the hell are those two black squares at each corner all about? Why is it only dumping out on a weird sideways angle? What’s the giant patch of blue all about? (doesn’t LOOK like there’s any “forced lake” in the code) Why is it all yellow, when the original had no yellow in it (am I screwing up alpha values?) How the hell can I store this data once generated, so I don’t need to refresh the whole thing every frame (thereby grinding the machine to a halt) etc etc etc.

Needless to say, there’s still quite a lot of work to get this game ready – let alone turn it into anything useful. That said, I got to learn a whole ton about injecting generic code into Stencyl, operating with external editors, debugging Haxe, the Haxe syntax and common objects and so on. So, definitely time well spent, even if it’s not anything particularly playable or useful.

play