[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Newbie needs help, what's the most efficient (or easiest) way to do this?



hmm. So to make a timer, I'd make an event that would, every second, subtract one from a number that I could call "timer?" I never thought of it that way. Actually, that's given me a new idea that would greatly simplify making a scoring system and a different way to control difficulty as well...

Instead of 3 timers, I'd only need one. It would start at a number that would vary between levels, and every second the timer's value is decreased by one. Typing a letter correctly would add to the timer, and that could also vary from level to level. Not only that, but it would save me the time of making 3 diffrent timers. Thanks for the hint!

On 2/5/07, Luke Paireepinart <rabidpoobear@xxxxxxxxx> wrote:


On 2/5/07, Charles Christie < sonicbhoc@xxxxxxxxx> wrote:
I would like to ask you guys another question. If you feel in the mood to help me out, feel free... but it turns out that I don't have as much time as I had hoped, because they (my teachers) want something I can demonstrate out by early May. >.< I need to get moving on this, and find some sprites if I can't contact my cousin any time soon...

Is there any way to get pygame to get the right y coordinates of a rect? because I would like to have my text on the right side of the screen and if I knew how to get that, it would be a walk in the park. I know you can do it with some sort of freaky math but I'm trying to figure out how. I'm pretty sure if I googled it longer I could have figured it out but I have 1 minute before I have to get out of this classroom...

A more difficult problem is the timers. I would like to have three of them, but I don't know how to use the pygame.time.Clock() other than setting a framerate. Does anybody have an example of how to use pygame.time.Clock () to keep track of how much time has elapsed since an event and only start after everything else has loaded? Because it would suck to have the clocks start while the program is still loading. That would ruin people's scores.

It's actually really simple to create custom timed events.
so after you load all your data, make the events.
for example, if you wanted to subtract fuel from the player every second & set a max time limit at 150 seconds, add a custom event that will trigger every second.
then in your event processing, if the event has occured, decrement fuel and increment timeLimit.  When this reaches 150, end the program or whatever.
look at pygame Event docs.