예제 #1
0
파일: unit.py 프로젝트: Shatnerz/glad
 def __init__(self, pos, owner, **kwargs):
   shape = Rect.createAtOrigin(32, 32)
   AbstractObject.__init__(self, pos, shape, **kwargs)
   
   self.owner = self #keep a copy of who the corpse belongs to
   
   self.collisionType = 'OBJ' #should add collision type for corpses, keys, and other stuff you can walk over
   
   self.currentAnimation = 'ANIM_BLOOD_'+str(random.randint(0,3))
   self.animationPlayer = animation.AnimationPlayer(glad.resource.resourceDict[self.currentAnimation], 0.2, True)
예제 #2
0
파일: unit.py 프로젝트: Shatnerz/glad
 def __init__(self, pos, shape = Rect.createAtOrigin(32, 32), hue=180, name='SOLDIER', slime=False, **kwargs):
   AbstractObject.__init__(self, pos, shape, **kwargs)
   
   self.collisionType = 'UNIT'
 
   #Default statistics  
   self.strength = 10
   self.dexterity = 10
   self.constitution = 10
   self.intelligence = 10
   self.armor = 10    
   self.level = 1
   
   self.life = 100
   self.mana = 100
   
   self.rangedWeapon = None
   self.meleeWeapon = None
   
   self.rangedDamage = 10
   self.meleeDamage = 10
   
   self.range = 400 #range for ranged weapon (in pixels)
   
   self.moveSpeed = 200
   
   #By default, have units face 'right'
   self.orientation = Vector(1,0)
   self.directionString = self.orientationToString() #may not be needed
   
   #self.name = "SOLDIER" #might as well be soldier by default, name used to load animations with current name format
   self.name=name
   self.slime=slime
   if self.slime:
       self.currentAnimation = 'ANIM_' + self.name + '_TEAM_' + str(self.team) +'_MOVE'
   else:
       self.currentAnimation = 'ANIM_' + self.name + '_TEAM_' + str(self.team) +'_MOVE' + self.orientationToString()
   
   self.animationTime = 0.2    
   self.animationPlayer = animation.AnimationPlayer(glad.resource.resourceDict[self.currentAnimation], self.animationTime , True)
   
   self.alwaysMove = False
   
   #turning
   self.turnTime = 0.08
   
   #Attacking
   self.attacking = False
   #attack animation
   self.attackTime = 0.1 #time attack frame is up
   self.attackTimer = 0
   self.animateAttack = False
   
   self.hue = hue #I thnk this is from my old method of team coloring - can probably be removed
예제 #3
0
파일: projectile.py 프로젝트: Shatnerz/glad
 def __init__(self, pos, shape, owner, moveDir, name='TEST', spin=False, speed=400, slime=False, **kwargs): #can probably get rid of spin and slime and use **kwargs, but not sure how
   
   AbstractObject.__init__(self, pos, shape, owner.team, moveDir, **kwargs)
   
   self.collisionType = 'PROJECTILE'
   
   self.owner = owner
   
   self.speed = speed
   
   self.damage = 25
   
   #NOTE: must use normalized direction vector!
   self.vel = moveDir.getNormalized()*self.speed
   
   self.orientation = Vector(moveDir)
   self.directionString = self.orientationToString()
   
   self.range = self.owner.range #arbitrary range in pixels for now, not in src they do line of sight * step size
   self.distance = 0 #distance traveled
   
   #Setup random waver for the projectile
   waver = self.speed/2 #absolute amount
   #waver = random.uniform(0,(waver)) - waver/2 #similar to openglad code
   gauss = random.gauss(0,0.25) #have a gaussian distribution just because i can
   if gauss > 1: gauss=1
   elif gauss < -1: gauss=-1
   waver = waver * gauss    
   #get vector perpendicular to direction 
   normVector = Vector(-1*self.vel[1],self.vel[0]).getNormalized() #the negative reciprocal of direction vector
   #Create vector for the waver
   waverVector = normVector*waver    
   #Add waver to velocity vector
   self.vel += waverVector
   
   self.sound = glad.resource.resourceDict['fwip']
   
   self.name=name
   if self.name == 'TEST':
     anim = animation.TestAnimation(size = shape.getSize())
     self.animationPlayer = animation.AnimationPlayer(anim, 1.0, True)
   else:
     if spin:
       self.currentAnimation = 'ANIM_' + self.name + '_SPIN'
     elif slime:
       self.currentAnimation = 'ANIM_' + self.name
     else:
       self.currentAnimation = 'ANIM_' + self.name +'_MOVE' + self.orientationToString()
     self.animationPlayer = animation.AnimationPlayer(glad.resource.resourceDict[self.currentAnimation], 0.2, True) #freezes if false
예제 #4
0
파일: tile.py 프로젝트: Shatnerz/glad
 def __init__(self, pos, tileNum, type = None, shape=Rect.createAtOrigin(32,32), **kwargs):
   
   AbstractObject.__init__(self, pos, shape, team=None, moveDir=None, **kwargs)
   
   self.collisionType = 'LAND'
   if tileNum in Tile.water:
     self.collisionType = 'WATER'
   elif tileNum in Tile.tree:
     self.collisionType = 'TREE'
   elif tileNum in Tile.wall:
     self.collisionType = 'WALL'
   elif tileNum in Tile.barrier:
     self.CollisionType = 'BARRIER'
   
   #set appropriate tile to be drawn
   self.tileNum = tileNum
   tileName = Tile.tileDict[self.tileNum]
   anim = [glad.resource.get(tileName)]
   self.currentAnimation = animation.Animation(anim)
   self.animationPlayer = animation.AnimationPlayer(self.currentAnimation, 0.2, True)