Charles Christie wrote:
>Wii will rock you
I lol'd.
Anyway, Let's see. The tools I need:
a clock. I suppose pygame.time.set_timer(pygame.USEREVENT + 1, 1000)
would be correct.
That would set a timer that, every 1000 miliseconds (that's one
second, right?), would call pygame.USEREVENT + 1 which would decrease
the number in a variable I call "timeleft."
So then I could make pygame.USEREVENT + 1 = timeleft - 1 or something
like that? (I'm pretty sure the syntax for that is wrong)
I don't think you are understanding the events correctly.
setting a timer for USEREVENT+1 will just make that event's type one
higher than USEREVENT, there's no kind of incrementing going on other
than that once during the declaration.
In essence, than you'd want to do is something along these lines:
pygame.time.set_timer(pygame.USEREVENT, 1000)
while 1:#game loop
for event in pygame.event.get():#as usual
if event.type == pygame.USEREVENT:#you wouldn't need the pygame here
if you did a 'from pygame.locals import *'
#this only happens 1ce a second
timeleft -= 1
if timeleft == 0:
print 'TIME OUT!"
Then, every 1000 miliseconds it would decrease timeleft by one, right?
In the above code it would. but make sure you notice that the event
itself does absolutely nothing, just like a keydown event or whatever.
You have to define what behavior you want to occur in the same way you
would with any other event.
Then I could have something that causes a "game over" event that would
wipe everything off of the screen and print "game over" and print your
scores, right? and I could even have a sort of "max combo" counter
thing, because that wouldn't be too hard to program either.
Yep!
HTH,
-Luke