The beginning of a new school term and a heavy cold both kept me away from the code for a few days - but I have managed to scrape a few updates together in the odd spare minute or two, so progress continues albeit at a slow pace.
I now have a nice wrapper-routine around the Random Number Generator, through which I can pass a range limit value and have a sensible value passed back. So, for example, I can pass '2' in and get a random number back in the range of 1 to 2 (a 50/50 chance); equally, I can pass '5' in, and get values in the range 1 to 5 back (which is a 20% chance). The wrapper code uses pre-calculated tables to split the 0-255 RNG values into 'n' bands, and currently there are just two sets of data to split values into 2 or 5 bands. However, the code has a small amount of robustness built-in - if I pass in a range limit which has no table data defined, it always returns 255 rather than just chewing through memory until hitting a BRK.
I've also written some object-initialiser code which handles the instantiation of Meanies (and anything else) when a new one is needed - this code was previously inlined in the main loop, and was both unwieldy and non-generalised, so it's much nicer now. Also, the decision logic for moving objects around has been separated-out and much-improved, and is now a lot slicker than before. I need to add a little bit of code to re-calculate Base Offset Bit settings when objects move across the mid-screen page boundary, but aside from that it's largely complete.
Next on the list is to generalise the code that is specific to Meanie movement, because at the moment it's duplicated for each of the two Meanie objects; it should be lifted-out and turned into a general-purpose routine, because it's exactly the same except for the bits that reference each Meanie object. That way, the code exists in just one place, and I can then have each Meanie 'mover' decision-maker call it with a pointer to the Meanie in question. At the same time as I rework this routine, I'll also add the last missing piece of the jigsaw, which is to update the 'delete' table with the objects' old position so that the main update routine can draw the objects in their new positions and zap them from the old.
There's about three or four hours' work there, including debugging time, which in theory means I can get these tasks done over the weekend, and be ready next week to crack on with the next crucial bit of code which checks for collisions and out-of-bounds positions (like where a Meanie falls off the bottom of the screen). I'm still hoping to finish the game by the end of September, but I'm not too worried if it runs into next month, as is now looking likely. It'll be great when it's done and I can publish the whole thing though - really looking-forward to getting feedback on it!

0 comments:
Post a Comment