Waves and Toasty Stuff
We've been working full steam on PP:AFAA tonight, and I've finally gotten back on track with Melba Toast and breaking out teh codez. I actually started out on prototyping water yesterday and thought I'd have an easy time of getting some wave action going... Boy was I wrong.
Actually in theory, it would have been pretty simple to just throw a line on the screen and use a sine wave to do some nice wave effects and the just move on. However, I have decided to use Melba Toast in the most responsible manner possible and that means avoiding shitty shortcuts and hacks. I determined that I wanted my water to be a tile, which means it has to be subjected to all the culling algorithms I wrote for my MelbaTiles. This set me right in the face of one of the two problems my tile engine currently has, the other of which is I have no faculty for actors which are able to move across the tile sectors (see Tile engine tutorial to get an idea of how the tile system works), and I only register tiles with the sector that contains their registration point, i.e. the upper left corner. This second issue is a problem for any tile which overlaps two sectors or especially tiles which are larger than a sector. I decided that the water shouldn't be split up into multiple objects, a decision I may change later for efficiency, which forced me to solve the problem of super sized tiles before I could even make my water show up on the screen.
So anyway, I came up with 14 different cases of tile orientation on a single sector and was about to write up a massive nested if() clusterfuck when I remembered the collision lessons the Metanet Software crew (makers of N, check it out) released. Using their "Maths", I was able to reduce the statement to about 8 lines of code and was very pleased with myself.
Long story short, there is no longer a limit to the size of tiles Melba Toast can support, and we got neato water effects, though it's not too dynamic at the moment. You can use the arrow keys to scroll around, but you can get lost quick.
Also, tilde brings down the console, though the only command right now is fps.
No comments:
Post a Comment