コード例 #1
0
ファイル: blocks.py プロジェクト: mappy13/nihil-ace
 def take_damage(self, amount):
     self.damage += amount
     if self.damage >= self.health and not self.has_exploded:
         # create an explosion
         self.has_exploded = True
         Explosion(self._body.position, BLOCK_SIZE,
                   velocity=self._body.velocity)
         # remove joints
         for block in self._adjacent_blocks:
             toremove = self._joints & block._joints
             for joint in toremove:
                 block._joints.remove(joint)
         SPACE.remove(*self._joints)
         self._joints = WeakSet()
         # remove ties to the construction
         for block in self._adjacent_blocks:
             block._adjacent_blocks.remove(self)
         self._adjacent_blocks = WeakSet()
     elif self.damage >= self.health * 2:
         Explosion(self._body.position, BLOCK_SIZE,
                   velocity=self._body.velocity)
         for i in range(random.randint(1,5)):
             Resource(self)
         SPACE.remove(self._body, self._shape)
         SPACE.blocks.remove(self)
         if self in SPACE.controllable_blocks:
             SPACE.controllable_blocks.remove(self)
         if self in SPACE.controller_blocks:
             SPACE.controller_blocks.remove(self)
コード例 #2
0
ファイル: resources.py プロジェクト: mappy13/nihil-ace
 def upkeep(self):
     if self.decay_chance > random.random():
         SPACE.remove(self._shape, self._body)
         SPACE.resources.remove(self)
     if hasattr(self._shape, "target") and self._shape.target():
         b = self._shape
         direction = b.target().position - b.body.position
         if direction.length < BLOCK_SIZE / 2:
             block = b.target()._get_block()
             if block:
                 block.resource_count += 1
             SPACE.resources.remove(self)
         # TODO: 160 is the radius of the field...
         #       let's get that dynamically
         direction.length = max(0.1, (160 - direction.length) / 160)
         b.body.apply_impulse(direction)
コード例 #3
0
ファイル: blocks.py プロジェクト: mappy13/nihil-ace
 def deactivate(self):
     SPACE.remove(self._tractor_link, self._tractor_body, self._tractor_shape)
     self._tractor_body = self._tractor_link = self._tractor_shape = None
コード例 #4
0
ファイル: blocks.py プロジェクト: mappy13/nihil-ace
 def deactivate(self):
     SPACE.remove(self._shield_link, self._shield_body, self._shield_shape)
     self._shield_body = self._shield_link = self._shield_shape = None
コード例 #5
0
ファイル: projectiles.py プロジェクト: mappy13/nihil-ace
 def upkeep(self):
     self.ttl -= 1
     if self.ttl < 1:
         SPACE.remove(self._shape, self._body)
         SPACE.projectiles.remove(self)
コード例 #6
0
ファイル: explosion.py プロジェクト: mappy13/nihil-ace
 def upkeep(self):
     self.ticks -= 1
     if self.ticks <= 0:
         SPACE.remove(self._body, self._shape)
         SPACE.explosions.remove(self)