예제 #1
0
파일: projectile.py 프로젝트: Shatnerz/glad
 def update(self, time):
   #Update as abstract object
   AbstractObject.update(self,time)
   
   if not self.owner.alive:
     self.alive = False
   
   if not self.returning:
     #Update distance traveled
     self.distance += self.vel.getNorm()*time    
     #Check to see if it hit max range yet
     if self.distance >= self.range:
       self.returning = True
   
   elif self.returning: #returns along straight line between knife and owner
     direction = self.pos - self.owner.pos
     direction = direction.getNormalized()
     self.vel = direction*self.speed
     
     #if util.getCollisionInfo(self.shape.translate(self.getPos()), self.vel, self.owner.shape.translate(self.owner.getPos()), self.owner.vel):
     #  time = util.getCollisionInfo(self.shape.translate(self.getPos()), self.vel, self.owner.shape.translate(self.owner.getPos()), self.owner.vel)[0]
     #  print time  
     
     #CHECK FOR COLLISION WITH OWNER
     #cant use onCollide because collision between unit and projectile of the same team are ignored
     if util.Rect.touches(self.shape.translate(self.getPos()), self.owner.shape.translate(self.owner.getPos())):
       #print "COLLISION"
       self.alive = False
예제 #2
0
파일: projectile.py 프로젝트: Shatnerz/glad
 def update(self,time):
   #Update as abstract object
   AbstractObject.update(self,time)
   
   #Update distance traveled
   self.distance += self.vel.getNorm()*time
   
   #Check to see if it hit max range yet
   if self.distance >= self.range:
     self.alive = False