Example #1
0
    def update(self, time):
        if self._destroyed:
            return False

        if self._t0 is None:
           self._t0 = time

        if self._follow is not None and not self._follow.closing() :

            d = self._follow._pos - self._pos

            T.unit_vector(d,d)

            self._dir = self._dir * (1-self._thrust) + d * self._thrust

            if time - self._t0 > 3000 or self._follow._destroyed:
                print "Not following anymore"

                self._follow = None

            Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
        else:
            # too simple to use Verlet
            Entity.moveTo(self, self._pos + self._dir * self._speed) # also updates _pos
            self._dir += self._gravity

        self._xform = mmult(self._pos_m,self._scaling_m, T.quaternion_matrix(self._rotation))
        self._rotation = T.quaternion_multiply(self._d_rotation, self._rotation)

        # hit the floor
        if self._map(self._pos[0], self._pos[1], False) > self._pos[2]:
            self.explode()
            return False # tell the scene the missile is toast

        return True
Example #2
0
    def update(self, time):
        if self._destroyed:
            return False

        if self._closing:
            self._scale -= 0.01
            self._scale = max(self._scale, 0)
            self._scale_m = T.scale_matrix(self._scale)
            if self._scale == 0:
                self._destroyed = True


        self._rot = T.quaternion_multiply(self._rot_speed, self._rot)
        self._anim_m = T.quaternion_matrix(self._rot)

        self._beacon_xform = self._pos_m

        self._geom_xform = mmult(self._pos_m, self._anim_m, self._scale_m)

        return True
Example #3
0
 def roll(self, axis):
     len = T.vector_norm(axis) * 5.0
     rot = T.quaternion_about_axis(-len, axis)
     self._rotation = T.quaternion_multiply(rot, self._rotation)