def __del__(_self): me.speed = _self.speed me.invincible = False me.mapobs = True me.entobs = True engine.destroyEntity(grapple)
def defaultState(self): p = system.engine.player self.anim = 'grow' while not self._animator.kill: if not self.creator: self.check = False break yield None self.anim = 'die' yield None while not self._animator.kill: if self.ent.specframe == 3 and self.creator in engine.entities: if not self.hit and self.check: ents = self.detectCollision( (0, 0, self.ent.hotwidth, self.ent.hotheight)) for e in ents: if e is p: p.hurt( self.damage, self.recoil, dir.fromDelta(self.creator.x - p.x, self.creator.y - p.y)) self.hit = True yield None engine.destroyEntity(self)
def defaultState(self): p = system.engine.player self.move(dir.UP, 100000) while self.y > -10: yield None self.stop() for x in range(100): yield None self.x = p.x + p.ent.hotwidth / 2 - 4 destY = p.y + p.ent.hotheight / 2 - 4 self.y = p.y - 300 engine.addEntity( SporeShadow( ika.Entity(self.x, destY, p.ent.layer, 'plant_shadow.ika-sprite'), self)) self.move(dir.DOWN, 100000) sound.fall.Play() while self.y < destY: yield None self.stop() sound.sporeHit.Play() self.speed = 0 self.ent.spritename = 'plant_explode.ika-sprite' self.anim = 'explode' self.x -= 12 self.y -= 12 sound.sporeHit.Play() oldLayer = self.ent.layer self.ent.layer = p.ent.layer ents = self.detectCollision( (0, 0, self.ent.hotwidth, self.ent.hotheight)) self.ent.layer = oldLayer for e in ents: if e is p: p.hurt(self.damage, self.recoil, ika.Random(0, 8)) while not self._animator.kill: yield None engine.destroyEntity(self) while True: yield None
def defaultState(self): while self.creator.ent.spritename == 'plant_spore.ika-sprite': dist = self.y - self.creator.y self.ent.specframe = 3 - (dist * 3 / 300) yield None engine.destroyEntity(self) while True: yield None
def defaultState(self): p = system.engine.player destY = self.y self.y -= 300 engine.addEntity( SporeShadow( ika.Entity(self.x, destY, p.ent.layer, 'maneater_shadow.ika-sprite'), self)) self.move(dir.DOWN, 100000) while self.y < destY: yield None self.stop() if self.play: sound.sporeHit.Play() self.speed = 0 self.ent.spritename = 'maneater_explode.ika-sprite' self.anim = 'explode' self.x -= 12 self.y -= 12 oldLayer = self.ent.layer self.ent.layer = p.ent.layer ents = self.detectCollision( (0, 0, self.ent.hotwidth, self.ent.hotheight)) self.ent.layer = oldLayer for e in ents: if e is p: p.hurt(self.damage, self.recoil, ika.Random(0, 8)) while not self._animator.kill: yield None engine.destroyEntity(self) while True: yield None
def defaultState(self): self.move(self.direction, 5) self.anim = 'fall' while True: if self.count < 50: self.count += 1 self.framecount += 1 if self.framecount > 8 and ika.Random(0, 6) == 0: self.framecount = 0 if self.direction == dir.DOWNLEFT: self.direction = dir.DOWNRIGHT else: self.direction = dir.DOWNLEFT self.move(self.direction, 5) yield None else: engine.destroyEntity(self) yield None
def update(self): if self.ent is not None and self.ent.ent is not None: self.timer += 1 if self.timer >= self.speed: self.curPos += 1 self.timer = 0 if self.curPos == 2 and not self.timer: self.ent.x = -1000 self.generatePowerup(self.ent) if self.curPos >= len(smoke): engine.destroyEntity(self.ent) return True else: return True
def grappleState(self, me): sound.grapple1.Play() direction = dir.straighten[me.direction] x = me.x y = me.y # HACK: work around rectangular hotspot junk. dx, dy = dir.delta[direction] if dx > 0: x += 16 if dy > 0: y += 16 if me.direction in (dir.UP, dir.DOWN): x += 7 if me.direction in (dir.LEFT, dir.RIGHT): y += 2 me.anim = 'grapplethrow' me.invincible = True grapple = _GrappleEntity(x, y, me.layer, direction) engine.addEntity(grapple) yield None # needed to give the grapple a moment to start moving while grapple.isMoving(): yield None dx, dy = dir.delta[grapple.direction] tx = grapple.x / ika.Tileset.width + dx ty = grapple.y / ika.Tileset.height + dy tile = ika.Map.GetTile(tx, ty, grapple.layer) grippableTiles = self.GRIPPABLE_TILES.get(ika.Map.tilesetname, ()) if tile in grippableTiles: me.state = self.pullState(me, grapple) else: me.invincible = False me.state = me.defaultState() engine.destroyEntity(grapple) yield None
def touch(self): self.apply() engine.destroyEntity(self) self.sound.Play()
def remove(self): self.x = self.y = -100 # hack! engine.destroyEntity(self)
def clearEnemies(): for e in engine.entities: if isinstance(e, Enemy): engine.destroyEntity(e)
def firstConvo(): #if 'firstconvo' not in engine.saveData: if False: xwin = ika.Map.xwin ywin = ika.Map.ywin stone = ika.Entity(110, 60, 1, 'artifact.ika-sprite') fish = Fish(ika.Entity(110, 60, 2, 'fish.ika-sprite')) fish.ent.mapobs = fish.ent.entobs = fish.ent.isobs = False fish.ent.speed = 300 engine.addEntity(fish) fried = Friedrich(ika.Entity(176, 60, 1, 'friedrich.ika-sprite')) fried.ent.speed = 120 fried.ent.mapobs = fried.ent.entobs = fried.ent.isobs = False fried.anim = 'fly' engine.addEntity(fried) engine.player.stop() engine.saveData['firstconvo'] = True engine.beginCutScene() ana = engine.player.ent ana.specframe = 0 engine.synchTime() text( "left", "anastasia3", "Pfft! I can't believe I came away empty handed today! If it wasn't for that flock of gulls I'd still have that seventy-pounder." ) delay(33) ana.specframe = 24 text("left", "anastasia3", "You hear me?! Give me back my fish!") sound.fall.Play() delay(75) fish.x, fish.y, fish.layer = (110, -20, ana.layer + 1) fish.move(dir.DOWN, 200) tick() while fish.isMoving(): tick() draw() engine.things.append(Quake(20)) ana.specframe = 23 apos = (ana.x, ana.y + 16 - ywin) text(apos, "anastasia2", "left", "Ouch!!!") delay(80) fried.x, fried.y = 176, 60 fried.move(dir.DOWN, 70) delay(1) while fried.isMoving(): delay(1) fpos = (160, fried.y + 24 - ywin) text(fpos, "Dropped something?") delay(100) text((ana.x - 8, ana.y + 24 - ywin), '...') delay(50) text((ana.x - 8, ana.y + 24 - ywin), 'Mmph..') ana.specframe = 1 fish.move(dir.DOWN, 32) fried.move(dir.DOWN, 70) delay(1) while fried.isMoving(): delay(1) ana.specframe = 3 text("left", "anastasia3", "That thing is heavy.. ") text( "left", "anastasia", "Oh, Friedrich! Did you scare that fish out of the gulls? It's good to see you, it's been almost a week!" ) text( "right", "friedrich", "Indeed! It has been quite some time. Oh, but I've got some stories for you!" ) text("left", "anastasia", "Yeah? Did you find any new treasure on that deserted island?") text( "right", "friedrich", "It was a very enlightening experience. I shall have to take you there someday. We'll plan a trip!" ) text("left", "anastasia", "Ooooh! Sounds like fun!") text( "right", "friedrich", "As a matter of fact, there is something I found that I'd like to show you at my shop. Swing by when you get a chance." ) text("left", "anastasia", "Sure! I need to get this fish down to Yolander anyway.") text("right", "friedrich", "Oh do take your time, dear.") engine.destroyEntity(fish) fried.move(dir.UP, 160) fried.anim = 'fly' tick() while fried.isMoving(): tick() draw() engine.destroyEntity(fried) engine.endCutScene() engine.synchTime() engine.things.append(Caption("Anastasia's House", font=engine.font2))
def slashState(self, me): if 0: me.overlay.renderscript = self.drawRect me.stop() me.anim = 'slash' r = slashRange[me.direction] thrust = False backslash = False backthrust = False # when we hit an entity, we append it here so that # we know not to hurt it again. hitList = set([]) sound.sword1.Play() while not me._animator.kill: rect = list(r[me._animator.index]) + [me.layer] rect[0] += me.x rect[1] += me.y ents = ika.EntitiesAt(*rect) for e in ents: if e is me.overlay or e in hitList: continue if e in engine.entFromEnt: x = engine.entFromEnt[e] if isinstance( x, Enemy) and not x.invincible and x not in hitList: hitList.add(x) x.hurt(int(me.stats.att), 120, me.direction) me.giveMPforHit() elif isinstance(x, Arrow): hitList.add(x) sound.deflect.Play() engine.destroyEntity(x) elif isinstance(x, _Powerup): x.touch() self.cutBush(me, rect) if (controls.up() or controls.joy_up()) and me.direction == dir.DOWN: backthrust = True elif (controls.down() or controls.joy_down()) and me.direction == dir.UP: backthrust = True elif (controls.left() or controls.joy_left()) and me.direction in [ dir.RIGHT, dir.UPRIGHT, dir.DOWNRIGHT ]: backthrust = True elif (controls.right() or controls.joy_right()) and me.direction in [ dir.LEFT, dir.UPLEFT, dir.DOWNLEFT ]: backthrust = True elif (controls.attack1() or controls.joy_attack1()) and not thrust: backslash = True elif (controls.attack2() or controls.joy_attack2()) and not backslash: thrust = True yield None if 0: me.overlay.renderscript = None if thrust: me.state = self.thrustState(me) elif backslash: me.state = self.backSlashState(me) else: # Stall: count = 8 while count > 0: count -= 1 #if controls.attack2(): # me.state = me.thrustState() yield None yield None
def die(self, *args): engine.destroyEntity(self)