def collide(self, other_object): distance = Util.dist(self.get_position(), other_object.get_position()) sum_r = self.get_radius() + other_object.get_radius() if distance > sum_r: return False else: return True
def rock_spawner(self): if self.is_started: if len(self.rock_group) >= Rock.LIMIT: return rock_pos = [random.randrange(0, self.canvas.CANVAS_WIDTH), random.randrange(0, self.canvas.CANVAS_HEIGHT)] rock_vel = [random.random() * .6 - .3, random.random() * .6 - .3] rock_avel = random.random() * .2 - .1 add_vel = self.score * 0.5 + 1 rock_vel = [rock_vel[0] * add_vel, rock_vel[1] * add_vel] rock = Rock(rock_pos, rock_vel, 0, rock_avel, self.canvas) distance = Util.dist(rock.get_position(), self.ship.get_position()) if distance < 200: return self.rock_group.add(rock)
def rock_spawner(self): if not self.started: return if len(self.rock_group.sprites()) >= Rock.LIMIT: return rock_pos = [random.randrange(0, self.area.width), random.randrange(0, self.area.height)] rock_vel = [random.random() * 1.3 - .3, random.random() * 1.3 - .3] rock_angle_vel = random.random() * 1.0 - .1 add_vel = self.score * 0.5 + 1 rock_vel = [rock_vel[0] * add_vel, rock_vel[1] * add_vel] rock = Rock(rock_pos, rock_vel, rock_angle_vel) distance = Util.dist(rock.rect.center, self.ship.rect.center) if distance < 200: return self.rock_group.add(rock)
def rock_spawner(self): if self.is_started: if len(self.rock_group) >= Rock.LIMIT: return rock_pos = [ random.randrange(0, self.canvas.CANVAS_WIDTH), random.randrange(0, self.canvas.CANVAS_HEIGHT) ] rock_vel = [random.random() * .6 - .3, random.random() * .6 - .3] rock_avel = random.random() * .2 - .1 add_vel = self.score * 0.5 + 1 rock_vel = [rock_vel[0] * add_vel, rock_vel[1] * add_vel] rock = Rock(rock_pos, rock_vel, 0, rock_avel, self.canvas) distance = Util.dist(rock.get_position(), self.ship.get_position()) if distance < 200: return self.rock_group.add(rock)