The score in my python game doesn't add up correctly -
so i've been making little game test myself , can't seem make score update @ all, please have help? edit: sorry being unspecific question, problem when asteroid goes past screen, first 1 gives ten points after score doesn't go up? think it's problem segment of code, i'd want after asteroid passed below screen, asteroid deleted , adds 10 points score. i'm livewires module well.
class asteroid(games.sprite): """ asteroid falls through space. """ image = games.load_image("asteroid_med.bmp") speed = 1 def __init__(self, x, y = 10): """ initialize asteroid object. """ super(asteroid, self).__init__(image = asteroid.image, x = x, y = y, dy = asteroid.speed) self.score = games.text(value = 0, size = 25, color = color.green, top = 5, right = games.screen.width-10) games.screen.add(self.score) def update(self): """ check if bottom edge has reached screen bottom. """ self.add_score() def add_score(self): if self.bottom > games.screen.height: self.score.value+=10 self.score.right = games.screen.width - 10 self.destroy()
you're destroying object after incrementing score.
Comments
Post a Comment