def update(self, delta): self.time -= delta if self.time > 0: return riged = self.gameObject.riged if riged: center = self.gameObject.shape.Center() world = self.gameObject.world radius = self.gameObject.shape.Radius() bdir = riged.velocity.normalize() if bdir.magnitude() == 0: bdir = self.catche self.catche = bdir (left, mid, right) = pygame.mouse.get_pressed() if left: self.gs.play() spos = center.add(bdir.scale(radius)) bdir = bdir.scale(500) Attacks.createBullet(self.gameObject,world, spos.x, spos.y-24, bdir.x, bdir.y, 5,damage=10, time = 2, ignores={'GameObject':[self.gameObject]},file_name='Resources/sprites/bullet.txt') self.time = .25 if right: self.ss.play() spos = center Attacks.createExplosion(self.gameObject, world, spos.x, spos.y, 40, damage = 10, time = .25, ignores={'GameObject':[self.gameObject]}, file_name='Resources/sprites/explosion1.txt') self.time = .5 pass if mid: pass
def doAttackShot(self,arg): bdir = Vector2.Vector2(0,0) cpos = self.gameObject.shape.Center() cpos.y -=24 if arg.has_key('target'): target = arg['target'] bdir = target.sub( cpos ).normalize() elif self.gameObject.riged: bdir = self.gameObject.riged.velocity spos = cpos.add(bdir.scale(self.gameObject.shape.Radius()*4)) bdir = bdir.scale(500) Attacks.createBullet(self.gameObject,self.gameObject.world, spos.x, spos.y, bdir.x, bdir.y, 5, damage = self.shotDamage, time = 2, ignores = {'type':[self.gameObject.type]},nockback=0, file_name='Resources/sprites/bullet.txt' )
def update(self, delta): self.time -= delta if self.time > 0: return riged = self.gameObject.riged if riged: bdir = riged.velocity.normalize() if bdir.magnitude() == 0: bdir = self.catche self.catche = bdir keys = pygame.key.get_pressed() if keys[pygame.K_j]: spos = self.gameObject.shape.Center().add(bdir.scale(self.gameObject.shape.Radius())) bdir = bdir.scale(500) Attacks.createBullet(self.gameObject, self.gameObject.world, spos.x, spos.y, bdir.x, bdir.y, 5, damage = 10, time=2, ignores={'GameObject':[self.gameObject]}, file_name='Resources/sprites/bullet.txt', nockback=10) #createBullet(self.gameObject,self.gameObject.world, spos.x, spos.y, bdir.x, bdir.y, 5) self.time = .1