Thanks I did it as you recommended. For anyone interested code is here: http://dpaste.com/hold/86501/
On Oct 23, 10:03 pm, Paul <[EMAIL PROTECTED]> wrote: > I still haven't looked at the code but let me try to express the general > idea in another way. > > Make a boolean variable for the player called is_shootable. > > Normally is_shootable is True. > > When the player presses the fire button, the program checks whether > is_shootable is True. If so, it shoots. If not, it does nothing (ie it > prevents the player from shooting). > > Lets say the player presses the fire button and is_shootable is True. Now > that the program has established that the player is able to shoot, three > things happen: > > 1. The program sets is_shootable to False (to prevent the player from firing > again right away). > > 2. A bullet is created with the correct velocity, direction etc. > > 3. The clock.schedule_once() method is used to schedule a function for some > time in the future, the time being equal to the period where the player will > not be able to shoot again. The only purpose of the function will be to set > is_shootable back to True. > > Once the time period expires, the function specified in > clock.schedule_once() is executed and is_shootable is set back to True, > allowing the player to shoot again. > > I hope this helps. > > Paul > > On Thu, Oct 23, 2008 at 6:47 PM, Drozzy <[EMAIL PROTECTED]> wrote: > > > Actually the code is here: > >http://dpaste.com/86496/ > > > The enemy i can make shoot like that, but the player actually creates > > a new bullet on the fly... > > I'll have to ponder about that.. thanks for advice though! > > > On Oct 22, 10:00 pm, Paul <[EMAIL PROTECTED]> wrote: > > > I don't know what the current code looks like but you could do something > > > like this: > > > > class Bullet: > > > __init__(self): > > > self.shootable = True > > > > def set_shootable(self, dt): > > > self.shootable = True > > > > def shoot(self): > > > if not self.shootable: return > > > # shoot > > > self.shootable = False > > > pyglet.clock.schedule_once(bullet.set_shootable, 0.5) > > > > On Wed, Oct 22, 2008 at 6:17 PM, Drozzy <[EMAIL PROTECTED]> wrote: > > > > > I am reprogramming the sample shooter.py that was presented by pyglet > > > > developers. > > > >http://video.google.co.uk/videoplay?docid=-8788197863800411145 > > > > > On of the things I am stuck on is slowing down the firing of the > > > > bullets from the player ship. > > > > > What I need to do is: > > > > -record the last time the bullet was fired > > > > -next time fire (mouse is clicked) is requested, see if enough > > > > interval is passed > > > > -if not don't shoot else shoot > > > > > Is it ok to use the datetime object for this or does pyglet have some > > > > kind of support with the scheduler for this? > > > > > Thank you! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pyglet-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pyglet-users?hl=en -~----------~----~----~----~------~----~------~--~---
