Ejemplo n.º 1
0
 def checkWaypoints(self):
     if self.wayPoints is not None:  
         # Compare distance between targetVector and currentPosition
         targetVector             = self.wayPoints[ self.activeWaypointIndex ]
         distance                 = Vector2D.fromPoints( self.position, targetVector )
         if distance.getVectorLength() < 10:
             
             self.activeWaypointIndex = (self.activeWaypointIndex + 1) % len( self.wayPoints )
             # Change to new direction
             targetVector             = self.wayPoints[ self.activeWaypointIndex ]
             # print "moving to next Waypoint " + str( targetVector )
             self.direction           = Vector2D.fromPoints( self.position, targetVector )
             self.direction.normalizeVector() 
Ejemplo n.º 2
0
 def setWaypointList(self, wpList):
     self.wayPoints = wpList
     # Recalc direction
     self.activeWaypointIndex = 0
     targetVector             = self.wayPoints[ self.activeWaypointIndex ]
     self.direction           = Vector2D.fromPoints( self.position, targetVector )
     self.direction.normalizeVector() 
Ejemplo n.º 3
0
    def handleMouseMovment(self, mousePos):
        if self.refToPlayer is not None:
            self.refToPlayer.setCrosshairPos(mousePos)

            if self.mouseButtonPressed is True:
                trgtVec = Vector2D(mousePos[0], mousePos[1])
                direction = direction = Vector2D.fromPoints(self.refToPlayer.position, trgtVec)
                direction.normalizeVector()
                self.refToPlayer.setMovment(direction, 20.0)