Here's a landscape / flight simulation engine that I have been playing with. I'm still figuring out how to turn this into a game, but at least it's functional now and runs at 30 fps.
It takes a few seconds to generate the map using simplex noise mapped onto a sphere.
Arrow keys to turn and pitch up and down.
Z-key to accelerate
There's a 3D shaded polygon engine built into this as well, but I'm not using it yet.
Thanks Anthony DiGirolamo for the simplex noise:
I'm at about 91% CPU right now. But if I can't squeeze more out of the engine, I can always shave a 5-10 pixels off of the left and right, change the clipping or draw distance. I think there's room before things get too chunky and noticeably degraded.
I don't think a simplified/demake magic carpet is out of the question.
I was looking through your code (you're shocked, I know) and saw this, and I'm wondering why you've got these extra parens in here:
function rotate_point(x,y,z) return (x)*mat00+(y)*mat10+(z)*mat20,(x)*mat01+(y)*mat11+(z)*mat21,(x)*mat02+(y)*mat12+(z)*mat22 end
Is this maybe copypasta from a C/C++ macro or something? I can't think of any other reason to have parens around the params like that.
I can't remember if parens incur a cycle cost, but they definitely add a token for each pair.
Ha good question-- yeah probably from a copypasta experience--perhaps I had a + offset in the parens or something at one time. If it gets tight for space, I'll definitely have to do some scrubbing.
Let me know if you see any other opportunities.
I was curious how well it could perform, so I diddled this and that and got it down from 0.9 to about 0.75. I didn't do anything amazing, just looked for loop invariants in the inner loop and a couple of places where I could put globals in locals to shave off cycles, pico-8-specific tricks, that sort of thing.
(I did this because optimizing is something I do for fun.)
I don't think you'd want to work on it in this optimized state, though, as it became less flexible and tweakable, but I wanted you to know you could potentially get this extra 15-20% speed if you need it down the road. I'm sure you're capable of it yourself, so I won't bother telling you what to do. :) Just thought you'd like to know the headroom is there.
(I will say that the main speedup came from putting more of the color/brightness calcs inside of the 'if' where you decide whether or not the existing height of the current column exceeds the height of what you're about to draw.)
[Please log in to post a comment]