Monday, October 3, 2011

Random Triggers for Falling Objects

I spent an hour tonight working with

time.time()

from the time module to create a timer for the game.  I'm using the elapsed time and a random number as the trigger to get the fish to drop a bomb.

The random number is generated with

random.randint(1, 8)


This was a bit more involved than I had anticipated.  I got the clock to work by creating a clock object and a gameClock function.  I then passed the clock object to the gameClock for updating.  The program is getting increasingly difficult to manage.  However, the playability is getting better.

In the original version, I used a random number that I stored in bomb.trigger and the bomb.rect.centerx value.  The end result is the same so far.  However, it's easier to change the frequency of the bomb drops using time.  I can simply shorten the time delay to cause the bombs to drop more frequently.

No comments:

Post a Comment