Changeset 446:3054c62f9d64 for nagslang


Ignore:
Timestamp:
Sep 7, 2013, 12:52:15 PM (7 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
rebase_source:
27184cbde82060ac18ce04bb628b0105cbf7d70d
Message:

Faster sheep running.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/enemies.py

    r415 r446  
    8080            self.physicser.remove_from_space()
    8181
    82     def set_direction(self, dx, dy):
    83         vec = vec_with_length((dx, dy), self.impulse_factor)
     82    def set_direction(self, dx, dy, force_factor=1):
     83        vec = vec_with_length((dx, dy), self.impulse_factor * force_factor)
    8484        self.angle = vec.angle
    8585        self.physicser.apply_impulse(vec)
     
    322322        vec = self.range_to_visible_protagonist()
    323323        prot = self.world.protagonist
    324         step = None
    325324        if vec is not None:
    326325            if prot.in_human_form() and vec.length < self.human_vision_range:
    327                 step = vec.int_tuple
     326                self.set_direction(vec.x, vec.y, 1.5)
     327                return
    328328            if prot.in_wolf_form() and vec.length < self.wolf_vision_range:
    329                 step = (-vec).int_tuple
    330         if step is None:
    331             step = self.random_move()
    332         self.set_direction(*step)
     329                vec = -vec
     330                self.set_direction(vec.x, vec.y, 3)
     331                return
     332        self.set_direction(*self.random_move())
    333333
    334334    @classmethod
Note: See TracChangeset for help on using the changeset viewer.