class SavePoint(Entity): SPRITE = 'savepoint.ika-sprite' __anim = { 'bounce': (( animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), animator.makeAnim(range(4), 10), ), True), } def __init__(self, ent): super(SavePoint, self).__init__(ent, self.__anim) self.direction = dir.DOWN self.isTouching = False self.interruptable = False self.invincible = True self.anim = 'bounce' def update(self): self.animate() t = self.touches(engine.player) if t and not self.isTouching: # bump the player backward, so he's not touching us anymore. effects.fadeOut(50, draw=engine.raw_draw) engine.player.stats.hp = 999 engine.player.stats.mp = 999 dx, dy = dir.delta[dir.invert[engine.player.direction]] engine.player.x += dx * 3 engine.player.y += dy * 3 # TODO: neato fadeout, etc. # "Do you wish to save?" "Yes/No" self.isTouching = True engine.raw_draw() saveloadmenu.saveMenu() effects.fadeIn(50, draw=engine.raw_draw) engine.synchTime() elif not t: self.isTouching = False
class Friedrich(Npc): SPRITE = 'friedrich.ika-sprite' _anim = { 'fly': (( animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), ), True) } def __init__(self, ent): super(Friedrich, self).__init__(ent, self._anim) anim = 'fly'
class Dancer(Npc): SPRITE = 'towndancer.ika-sprite' SPRITE2 = 'towndancer2.ika-sprite' _anim = { 'dance': (( animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), animator.makeAnim((0, 1), 20), ), True) } def __init__(self, ent): super(Dancer, self).__init__(ent, self._anim) self.anim = 'dance'
def __init__(self, ent): Enemy.__init__(self, ent, _beamanim, None) flyAnim = animator.makeAnim(range(10), 10) self.stats.maxhp = 10 self.stats.hp = self.stats.maxhp self.stats.att = 52 self.invincible = True self.anim = 'flyAnim' self.name = 'beam' ent.mapobs = ent.entobs = False self.state = self.flyState() p = system.engine.player self.x = self.px = self.ent.x self.y = self.py = self.ent.y dx = (self.x - 8) - (p.x + 7) dy = (self.y - 8) - (p.y + 8) self.angle = math.atan2(dy, dx) + math.pi
from powerup import RedBerry, Seashell from quake import Quake _maneaterAnim = { 'idle': (( ((0, 1000), ), ((0, 1000), ), ((0, 1000), ), ((0, 1000), ), ((0, 1000), ), ((0, 1000), ), ((0, 1000), ), ((0, 1000), ), ), False), 'wait_in': (( animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), animator.makeAnim((7, 6, 5, 6), 20), ), True), 'wait_out': (( animator.makeAnim((12, 13, 14, 15, 14, 13), 20), animator.makeAnim((12, 13, 14, 15, 14, 13), 20), animator.makeAnim((12, 13, 14, 15, 14, 13), 20), animator.makeAnim((12, 13, 14, 15, 14, 13), 20), animator.makeAnim((12, 13, 14, 15, 14, 13), 20), animator.makeAnim((12, 13, 14, 15, 14, 13), 20),
import ika import engine from xi import textbox from entity import Entity from npc import Npc import animator _friedAnim = { 'fly': (( animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), animator.makeAnim((2, 3), 20), ), True) } class Friedrich(Npc): SPRITE = 'friedrich.ika-sprite' def __init__(self, ent): super(Friedrich, self).__init__(ent, _friedAnim) anim = 'fly'
import animator import Brain import dir import ending import xi.effects import math import player import sound from enemy import Enemy from carnivore import Carnivore from anklebiter import AnkleBiter from devourer import Devourer # arbitrary :D _idleAnim = animator.makeAnim((0, 4, 0, 0, 0, 4, 0, 0, 1, 2, 3, 2, 1, 0), 50) #_biteAnim = animator.makeAnim(range(16, 22), 7) # could do some speed-tinkering here. Make the first and last frames slower than the middle ones. _biteAnim = animator.makeAnim( [16] + range(16, 22) + [21], 7 ) # could do some speed-tinkering here. Make the first and last frames slower than the middle ones. _stareAnim = animator.makeAnim((4, 5, 5, 6, 6, 7, 7, 6, 5, 4, 4), 6) _roarAnim = animator.makeAnim((12, 13, 13, 14, 15, 16, 16, 16, 14, 12), 20) #_deathAnim = animator.makeAnim(range(24, 27), 100) _appearAnim = animator.makeAnim((26, 25, 24), 20) _deathAnim = animator.makeAnim(range(28, 36) + [27, 27], 16) _hurtAnim = ((10, 50), ) _anim = { 'idle': ((_idleAnim, ) * 8, True), 'bite': ((_biteAnim, ) * 8, False),
import ika import math import system import engine import player import Brain import animator import sound import dir from enemy import Enemy from entity import Entity _jellyAnim = { 'walk': (( animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((0, 1, 2, 3), 20), ), True ), 'grow': (( animator.makeAnim((4, 5, 6, 7), 20), animator.makeAnim((4, 5, 6, 7), 20), animator.makeAnim((4, 5, 6, 7), 20),
class Bone(Entity): SPRITE = 'frankenhead_bone.ika-sprite' ANIM = { 'twirl': (( animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), animator.makeAnim(range(0, 4), 10), ), True), 'explode': (( animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), ), False), } def __init__(self, ent, speed=175, damage=10, recoil=250): super(Bone, self).__init__(ent, self.ANIM) self.invincible = True self.speed = speed self.damage = damage self.recoil = recoil self.ent.mapobs = False self.ent.entobs = False self.ent.isobs = False self.state = self.defaultState() def defaultState(self): p = engine.player destY = self.y + 300 engine.addEntity( BoneShadow( ika.Entity(self.x, destY, p.ent.layer, 'frankenhead_shadow.ika-sprite'), self)) self.anim = 'twirl' self.move(dir.DOWN, 100000) while self.y < destY: yield None self.stop() self.speed = 0 self.ent.spritename = 'frankenhead_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
class Spore(Entity): SPRITE = 'plant_spore.ika-sprite' ANIM = { 'explode': (( animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), animator.makeAnim(range(0, 6), 10), ), False), } def __init__(self, ent, speed=200, damage=14, recoil=200): super(Spore, self).__init__(ent, self.ANIM) self.invincible = True self.speed = speed self.damage = damage self.recoil = recoil self.ent.mapobs = False self.ent.entobs = False self.ent.isobs = False self.state = self.defaultState() 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
import ika from enemy import Enemy import player import Brain import animator import sound import math import system import dir _ankleBiterAnim = { 'walk': (( animator.makeAnim(range(10, 15), 10), animator.makeAnim(range(15, 20), 10), animator.makeAnim(range(5,10), 10), animator.makeAnim(range(0,5), 10), animator.makeAnim(range(10, 15), 10), animator.makeAnim(range(15, 20), 10), animator.makeAnim(range(10, 15), 10), animator.makeAnim(range(15, 20), 10), ), True ), 'idle': (( ((10, 1000),), ((15, 1000),), ((5, 1000),), ((0, 1000),), ((10, 1000),),
from effects import Nova, Bolt from serpent import Serpent from xi import gui PLAYER_SPRITE = 'protagonist.ika-sprite' SLASH_LEVEL = 3 BACK_LEVEL = 6 THRUST_LEVEL = 9 # one entry for each direction _playerAnim = { 'walk' : (( animator.makeAnim(range(28, 36), 8), animator.makeAnim(range(19, 27), 8), animator.makeAnim(range(10, 18), 8), animator.makeAnim(range(1, 9), 8), animator.makeAnim(range(28, 36), 8), animator.makeAnim(range(19, 27), 8), animator.makeAnim(range(28, 36), 8), animator.makeAnim(range(19, 27), 8), ), True ), 'slash': (( zip(range(63,68), (8,6,4,2,8)), zip(range(54,59), (8,6,4,2,8)), zip(range(45,50), (8,6,4,2,8)),
import ika import math import system import player import Brain import animator import sound import dir from enemy import Enemy from entity import Entity _bugAnim = { 'walk': (( animator.makeAnim((8, 9), 6), animator.makeAnim((10, 11), 6), animator.makeAnim((6, 7), 6), animator.makeAnim((4, 5), 6), animator.makeAnim((8, 9), 6), animator.makeAnim((10, 11), 6), animator.makeAnim((8, 9), 6), animator.makeAnim((10, 11), 6), ), True ), 'idle': (( ((2, 1000),), ((3, 1000),), ((1, 1000),), ((0, 1000),),
import math import dir _anim = { 'idle': (( ((7, 1000), ), ((14, 1000), ), ((21, 1000), ), ((0, 1000), ), ((7, 1000), ), ((14, 1000), ), ((7, 1000), ), ((14, 1000), ), ), True), 'walk': (( animator.makeAnim(range(8, 14), 15), animator.makeAnim(range(15, 21), 15), animator.makeAnim(range(22, 28), 15), animator.makeAnim(range(1, 7), 15), animator.makeAnim(range(8, 14), 15), animator.makeAnim(range(15, 21), 15), animator.makeAnim(range(8, 14), 15), animator.makeAnim(range(15, 21), 15), ), True), 'hurt': (( ((45, 1000), ), ((38, 1000), ), ((31, 1000), ), ((52, 1000), ), ((45, 1000), ), ((38, 1000), ),
class ManeaterTentacle(Enemy): SPRITE = 'maneater_tentacle.ika-sprite' ANIM = { 'idle': (( animator.makeAnim((10, 11), 20), animator.makeAnim((6, 7), 20), animator.makeAnim((10, 11), 20), animator.makeAnim((6, 7), 20), animator.makeAnim((10, 11), 20), animator.makeAnim((6, 7), 20), animator.makeAnim((10, 11), 20), animator.makeAnim((6, 7), 20), ), True), 'grow': (( animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), animator.makeAnim((0, 1, 2, 3), 10), ), False), 'submerge': (( animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), ), False), 'attack': (( animator.makeAnim((16, 17), 20), animator.makeAnim((18, 19), 20), animator.makeAnim((13, 14), 20), animator.makeAnim((11, 12), 20), animator.makeAnim((16, 17), 20), animator.makeAnim((18, 19), 20), animator.makeAnim((16, 17), 20), animator.makeAnim((18, 19), 20), ), False), 'hurt': (( animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), animator.makeAnim((20, 21, 22, 23), 10), ), False), } ATKRANGE = [(-8, 0, 8, 16), (16, 0, 8, 16), (0, -8, 16, 8), (0, 16, 16, 8), (-8, 0, 8, 16), (16, 0, 8, 16), (-8, 0, 8, 16), (16, 0, 8, 16)] def __init__(self, ent, creator): super(ManeaterTentacle, self).__init__(ent, self.ANIM, Brain.Brain()) self.speed = 0 # Test code: # Equal probability of attacking or doing nothing. self.addMoods((Brain.Attack(1), self.attackMood), ) self.stats.maxhp = self.stats.hp = 60 self.stats.att = 25 self.stats.exp = 0 self.stats.money = 0 self.recoil = 200 self.ent.isobs = False self.ent.entobs = False self.creator = creator self.mood = self.attackMood self.state = self.growState() self.powerup = RedBerry self.hit = False def attackMood(self): p = engine.player self.anim = 'idle' cnt = 0 while True: dist = math.hypot(p.x - self.x, p.y - self.y) if dist < 40: yield self.attackState( dir.fromDelta(p.x - self.x, p.y - self.y)) if cnt >= 500: self.mood = self.submergeMood yield self.idleState() break else: cnt += 1 yield self.idleState(1) def submergeMood(self): p = engine.player yield self.submergeState() yield self.idleState(150) while True: dist = math.hypot(p.x - self.x, p.y - self.y) if dist > 100: yield self.growState() self.mood = self.attackMood break elif dist < 20: d = max(1, self.stats.att - p.stats.pres) p.hurt(d, self.recoil, self.direction) yield self.growState() self.mood = self.attackMood yield self.idleState() break else: engine.addEntity( ManeaterSpear( ika.Entity(p.x - 8, p.y - 8, self.layer, 'plant_tentacle.ika-sprite'), self)) yield self.idleState(60) yield self.idleState() def growState(self): sound.maneaterHead.Play() ents = self.detectCollision( [0, 0, self.ent.hotwidth, self.ent.hotheight]) while len(ents) > 1: ents = self.detectCollision( [0, 0, self.ent.hotwidth, self.ent.hotheight]) yield None self.anim = 'grow' self.ent.isobs = True self.invincible = False self.hit = False while not self._animator.kill: yield None yield None def submergeState(self): sound.maneaterHead.Play() self.anim = 'submerge' self.ent.isobs = False self.invincible = True while not self._animator.kill: yield None yield None def attackState(self, direction): class SpeedSaver(object): def __init__(_self): _self.s = self.speed def __del__(_self): self.speed = _self.s ss = SpeedSaver() self.direction = direction self.anim = 'attack' self.stop() while self._animator.index == 0: yield None sound.tentacleStrike.Play() while not self._animator.kill: ents = self.detectCollision( [-8, -8, self.ent.hotwidth + 16, self.ent.hotheight + 16]) for e in ents: if e == engine.player and not self.hit: d = max(1, self.stats.att - e.stats.pres) e.hurt(d, self.recoil, self.direction) self.hit = True yield None self.hit = False self.anim = 'idle' yield None self.stop() def hurtState(self, recoilSpeed, recoilDir): if self.stats.hp > 0: sound.enemyHit.Play() self.mood = self.submergeMood return super(ManeaterTentacle, self).hurtState(0, recoilDir) def idleState(self, time=50): while time > 0: time -= 1 yield None return
import ika import math import system import Brain import animator import sound import dir from enemy import Enemy from entity import Entity _goblinAnim = { 'walk': (( animator.makeAnim((4, 5), 10), animator.makeAnim((6, 7), 10), animator.makeAnim((2, 3), 10), animator.makeAnim((0, 1), 10), animator.makeAnim((4, 5), 10), animator.makeAnim((6, 7), 10), animator.makeAnim((4, 5), 10), animator.makeAnim((6, 7), 10), ), True), 'idle': (( ((4, 1000), ), ((6, 1000), ), ((2, 1000), ), ((0, 1000), ), ((4, 1000), ), ((6, 1000), ), ((4, 1000), ), ((6, 1000), ),
class Tentacle(Entity): SPRITE = 'plant_tentacle.ika-sprite' ANIM = { 'grow': (( animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), animator.makeAnim((0, 1), 40), ), False), 'die': (( animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), animator.makeAnim((2, 3, 4), 40), ), False), } def __init__(self, ent, creator, speed=100, damage=7, recoil=200): super(Tentacle, self).__init__(ent, self.ANIM) self.invincible = True self.speed = speed self.damage = damage self.recoil = recoil self.ent.isobs = False self.ent.entobs = False self.creator = creator self.check = True self.state = self.defaultState() self.hit = False 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)
import ika from enemy import Enemy import player import Brain import animator import sound import math import system import dir _razorManeAnim = { 'walk': (( animator.makeAnim(range(7,14), 9), animator.makeAnim(range(14, 21), 9), animator.makeAnim(range(21, 28), 9), animator.makeAnim(range(0,7), 9), animator.makeAnim(range(7,14), 9), animator.makeAnim(range(14, 21), 9), animator.makeAnim(range(7,14), 9), animator.makeAnim(range(14, 21), 9), ), True ), 'idle': (( ((7, 1000),), ((14, 1000),), ((21, 1000),), ((0, 1000),), ((7, 1000),),
import engine import sound import animator from entity import Entity from caption import DamageCaption _powerupAnim = { 'idle': (( animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), animator.makeAnim((0, 1, 2, 1), 10), ), True ), } class _Powerup(Entity): def __init__(self, ent, *args, **kwargs): super(_Powerup, self).__init__(ent, _powerupAnim) self.invincible = True self.anim = 'idle' self.direction = 0 self.args = args
import ika import math import system import engine import Brain import animator import sound import dir from enemy import Enemy from entity import Entity _frankenheadAnim = { 'walk': (( animator.makeAnim((8, 9, 10, 11), 20), animator.makeAnim((12, 13, 14, 15), 20), animator.makeAnim((4, 5, 6, 7), 20), animator.makeAnim((0, 1, 2, 3), 20), animator.makeAnim((8, 9, 10, 11), 20), animator.makeAnim((12, 13, 14, 15), 20), animator.makeAnim((8, 9, 10, 11), 20), animator.makeAnim((12, 13, 14, 15), 20), ), True), 'idle': (( ((8, 1000), ), ((12, 1000), ), ((4, 1000), ), ((0, 1000), ), ((8, 1000), ), ((12, 1000), ), ((8, 1000), ),