コード例 #1
0
ファイル: ant.py プロジェクト: jeremyosborne/ant_cities
    def process(self, time_passed):
        Entity.process(self, time_passed)

        energy = self.c["attrs"].get("energy")
        health = self.c["attrs"].get("health")

        # Should the ant die?
        if health.val <= 0:
            self.flags.add("dead")
            return

        # Burn energy each turn.
        energy.val -= 2.*time_passed

        # Is ant energy so low that we need to dump health into energy?
        if energy.val == 0:
            energy.val += 100
            health.val -= 10
        
        # Heading matches course of velocity.
        self.c["facing"].set(self.c["velocity"].course)
コード例 #2
0
ファイル: leaf.py プロジェクト: jeremyosborne/ant_cities
 def process(self, time_passed):
     Entity.process(self, time_passed)
     if self.c["age"].old:
         self.flags.add("dead")