[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?
>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)
Then, every 1000 miliseconds it would decrease timeleft by one, right?
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.
On 2/6/07, Luke Paireepinart <rabidpoobear@xxxxxxxxx> wrote:
Charles Christie wrote:
> 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!
>
Sure!
I'm a bit ashamed to admit it, but I made a parallax side-scrolling game
where the scrolling was all controlled by different events... even the
player!
Well, what can I say... It was a game-programming competiton (72hrGDC),
so I guess that means that anything 'working' is good.
And we got it done on time. :)
Anyway... Glad I sparked some innovation in you.
Are you considering competing in Pyweek in April? It might be a good
break! If you consider a week of late nights and rapid hacky coding to
be relaxing :P
Nevertheless, lots of fun. Would be cool to see you there.
Let me know if you have any trouble getting the events to add themselves
to the queue.
http://72hourgdc.com/board/downloads.php
Our entry is called Wii Will Rock You if you want to check it out.
The music is good, at least. :)
> On 2/5/07, *Luke Paireepinart* <rabidpoobear@xxxxxxxxx
> <mailto:rabidpoobear@xxxxxxxxx>> wrote:
>
>
>
> On 2/5/07, *Charles Christie* < sonicbhoc@xxxxxxxxx
> <mailto: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.
>
>
>