def update(self,asteroids,asteroid_count): self.life += 1 for a in asteroids: if pc.distance(self,a) < a.size: self.alive = False return #if shooting, wait before creating another bullet if self.createBullet == False and time.time() - self.bullet_wait >= 0.2: self.createBullet = True
def update(self,asteroids,asteroid_count): self.life += 1 #check if being hit by asteroid for a in asteroids: if pc.distance(self,a) < a.size: self.alive = False return #if shooting, wait before creating another bullet # if self.createBullet == False and time.time() - self.bullet_wait >= 0.2: # self.createBullet = True self.bullet_wait += 1 if self.createBullet == False and self.bullet_wait >= BULLET_FRAMES: # number of frames between bullets self.createBullet = True # TODO set maximum number of frames to penalize poor shooting if self.life > 2000: self.alive = False
def check_bullets(self, ship, asteroids, bullets): for b in bullets: if pc.distance(self, b) < self.size: if self.level == 1: ship.score += 20 elif self.level == 2: ship.score += 50 elif self.level == 3: ship.score += 100 #print("Score:", ship.score) asteroids.remove(self) bullets.remove(b) self.level += 1 if self.level in [2, 3]: for i in range(2): new_a = Asteroid(self.size / 2) new_a.x, new_a.y = self.x, self.y new_a.level = self.level asteroids.append(new_a)
def update(self,asteroids,asteroid_count): for a in asteroids: if pc.distance(self,a) < a.size: self.lives -= 1 time.sleep(2) self.create_asteroids = True