Nov-01-2019, 06:42 AM
(Oct-31-2019, 09:46 PM)SheeppOSU Wrote: ifnow - self.last >= self.cooldown
is true then its code will just counteract the one above
I think you meant to do this
def update(self): self.pos += self.vel * self.game.dt self.rect.center = self.pos if self.game.player.weapon == 'boomerang': now = pg.time.get_ticks() if now - self.last >= self.cooldown: self.pos -= self.vel * self.game.dt else: self.pos += self.vel * self.game.dt self.rect.center = self.pos
I did this and now it is flying the time of the cool down and then it just stands there and waits till it gets removed.
My update section is looking like this:
def update(self): self.pos += self.vel * self.game.dt self.rect.center = self.pos if self.game.player.weapon == 'boomerang': now = pg.time.get_ticks() if now - self.last >= self.cooldown: self.pos -= self.vel * self.game.dt else: self.pos += self.vel * self.game.dt self.rect.center = self.pos if pg.sprite.spritecollideany(self, self.game.walls): self.kill() if pg.time.get_ticks() - self.spawn_time > WEAPONS[self.game.player.weapon]['lifetime']: self.kill()What am I doing wrong?