Ejemplo n.º 1
0
 def __init__(self, x, y, sprite='boom.ika-sprite', framecount=4):
     super(Boom, self).__init__(ika.Entity(x, y, engine.player.layer,
                                           '%s/%s' %
                                           (config.sprite_path, sprite)))
     self.set_animation_state(first=0, last=framecount - 1, delay=4, loop=False)
     self.check_obs = False
     sound.play('Boom', 0.2)
Ejemplo n.º 2
0
 def Death(self):
     sound.play('Zombie-die')
     self.vx = 0
     self.set_animation_state(8 * self.direction + 56,
                              8 * self.direction + 63, 5, loop=False)
     while not self.anim.kill:
         yield None
     # Destroys the sprite when its state is done.
     self.destroy = True
     yield None
Ejemplo n.º 3
0
    def __init__(self, x, y, layer, target):
        super(Shield, self).__init__(x,y,layer)
        self.target=target #entity that is being shielded

        self.xdiff=target.x-x
        self.ydiff=target.y-y
        #angleInDegrees = atan2(deltaY, deltaX) * 180 / PI
        self.angle=int(math.atan2(self.ydiff, self.xdiff) * 180 / math.pi)

        self.ticks=0
        self.lifetime=64 #lasts 64 ticks

        sound.play('Boom', 0.2)
Ejemplo n.º 4
0
    def __init__(self, x, y, direction):
        super(Bullet, self).__init__(ika.Entity(int(x), int(y),
                                                engine.player.layer,
                                                '%s/bullet.ika-sprite' %
                                                config.sprite_path))
        self.vx, self.vy, frame = data[direction]
            

        self.vx=self.vx*3
        self.vy=self.vy*3 
        
        self.set_animation_state(first=frame, last=frame, delay=0, loop=False)
        self.ticks = 0
        self.temp = ika.Random(80, 280)
        sound.play('Shoot', 0.2)
        self.damage= 8 #bullet currently does 8hp of damage
Ejemplo n.º 5
0
    def SavePrompt(self, heal=True):
        if heal:
            self.player.dhp = self.player.maxhp
            self.player.dmp = self.player.maxmp
        selected = 0

        while not controls.confirm.Pressed():

            self.player.update()
            self.draw()

            Window(150, 0).draw(52, 60)
            print >> fonts.one(68, 80), 'Do you want to save?'

            x = 100
            y = 98
            for i, option in enumerate(['Yes', 'No']):
                f = [fonts.five, fonts.three][i == selected]
                print >> f(x, y), option
                x += 100


            self.hud.draw()
            #ika.Video.DrawRect(80 + 110 * selected, 92, 120 + 110 * selected,
            #                   108, ika.RGB(128, 192, 128))
            ika.Video.ShowPage()
            ika.Input.Update()
            if controls.left.Pressed():
                sound.play('Menu')
                selected -= 1
                if selected < 0:
                    selected = 1
            if controls.right.Pressed():
                sound.play('Menu')
                selected += 1
                if selected > 1:
                    selected = 0

        #for c in controls.control_list:
        #    c.Release()


        if selected == 0:
            self.Save()
            return True

        return False
Ejemplo n.º 6
0
 def Hurt(self, bullet):
     self.hp -= bullet.damage
     if self.hp <= 0:
         self.state = self.Death
         # Hack so that you can't kill the zombie again, or him hurt
         # you while he's dying.
         self.hurtable = False
     else:
         sound.play('Zombie-groan')
         if abs(self.vx) <= abs(self.basevx):
             self.set_animation_state(3 + self.direction * 3,
                                      3 + self.direction * 3, 12,
                                      loop=False)
         else:
             self.set_animation_state(4 + self.direction,
                                      4 + self.direction, 8, loop=False)
         self.hurt = True
Ejemplo n.º 7
0
    def __init__(self, x, y, direction):
        super(Beam, self).__init__(ika.Entity(int(x), int(y),
                                                engine.player.layer,
                                                '%s/blank.ika-sprite' %
                                                config.sprite_path))   
        self.ticks = 0
        self.temp = ika.Random(80, 280)
        sound.play('Beam', 0.2)
        self.damage = 20 

        self.vx, self.vy, frame = data[direction]
        self.vx=self.vx*4
        self.vy=self.vy*4
                
        self.endx=self.x=int(x)
        self.endy=self.y=int(y)        
        self.moving=True
        self.visible=True
Ejemplo n.º 8
0
    def __init__(self, x, y, angle, spawner, damage=8):
        super(Laser, self).__init__(ika.Entity(int(x), int(y),
                                    ika.Map.FindLayerByName('Walls'),
                                    '%s/blank.ika-sprite' %
                                    config.sprite_path))
        self.phantom = True
        self.check_obs = False
        self.ticks = 0
        self.angle = angle
        self.set_animation_state(first=0, last=0, delay=1)
        self.state = self.fly_state
        self.damage = damage
        self.spawner = spawner
        self.length = 16
        self.a = 255
        self.d = -1
        self.hurtable=False

        sound.play('Shoot', 0.2)
Ejemplo n.º 9
0
 def door_state(self):
     while True:
         while self.locked:
            yield None
         # Delay for a moment.
         i = 2
         while i > 0:
             i -= 1
             yield None
         # If close enough, start opening the door.
         if detect_in_y_coordinates(self) is engine.player and \
            abs(self.x - engine.player.x) < 72:
             if not self.dopen:
                 self.dopen = True
                 sound.play('Open')
             if self.anim.cur_frame < 8:
                 self.anim.cur_frame += 1
                 if self.anim.cur_frame >= 4:
                     # Not an obstruction at this point.
                     self.sprite.isobs = False
                     for i in range(4):
                         ika.Map.SetObs(self.x / ika.Map.tilewidth,
                                        self.y / ika.Map.tileheight + i,
                                        self.layer, False)
         # Or else close if not open.
         elif self.anim.cur_frame > 0:
             if self.anim.cur_frame < 4:
                 # Obstruction now.
                 self.sprite.isobs = True
                 for i in range(4):
                     ika.Map.SetObs(self.x / ika.Map.tilewidth,
                                    self.y / ika.Map.tileheight + i,
                                    self.layer, True)
             if self.dopen:
                 self.dopen = False
                 sound.play('Close')
             self.anim.cur_frame -= 1
         yield None
Ejemplo n.º 10
0
    def menu(self):
        controls.cancel.Pressed()
        self.mapname = ika.Map.GetMetaData()['name']
        sound.play('Whoosh')
        self.menuselected = 0
        time = ika.GetTime()
        ika.Input.Unpress()
        ika.Input.Update()
        while not controls.cancel.Pressed():
            t = ika.GetTime()
            while t > time:
                time += 1
                engine.ticks += 1
            engine.update_time()
            self.draw_menu()




            ika.Video.ShowPage()
            ika.Input.Update()
            if controls.right.Pressed():
                i = 0
                while self.options[self.menuselected] not in self.enabled or i == 0:
                    i=1
                    self.menuselected += 1
                    if self.menuselected > 4:
                        self.menuselected = 0
                sound.play('Menu')


            if controls.left.Pressed():
                i = 0
                while self.options[self.menuselected] not in self.enabled or i == 0:
                    i = 1
                    self.menuselected -= 1
                    if self.menuselected < 0:
                        self.menuselected = 4
                sound.play('Menu')

            if controls.confirm.Pressed(): #enter actual menu for that screen
                [self.mapscreen, lambda: None, lambda: None, self.preferences,
                 ika.Exit][self.menuselected]() #Need to make Quit return to main menu instead of exit entirely. 
                
        sound.play('Whoosh2')
Ejemplo n.º 11
0
    def preferences(self): #control config menu

        time = ika.GetTime()
        ika.Input.Unpress()
        ika.Input.Update()
        scroll = True
        optselected = 0
        selectmode=0 #0=selecting which control, 1=waiting for key to replace
        while not controls.cancel.Pressed():


            t = ika.GetTime()
            while t > time:
                time += 1
                engine.ticks += 1


            engine.update_time()
            self.draw_menu()
            self.draw_options()

            #ika.Video.Blit(self.select2, 14, 46 + 12 * optselected) #ugly
            ika.Video.DrawRect(17, 59 + 12 * optselected, 100, 67+12*optselected, ika.RGB(100,255,100,64),1)
            ika.Video.ShowPage()
            ika.Input.Update()

            #select up/down
            opt = controls.down.Pressed() - controls.up.Pressed()
            if opt:
                optselected += opt
                optselected %= len(self.configkeys)
                sound.play('Menu')

            if controls.confirm.Pressed():
                ika.Input.Unpress()
                ika.Input.keyboard.ClearKeyQueue()
                done = False
                #select controls
                while not done: #start processing for a new key

                    #duplicate code, future revision to move into main function
                    t = ika.GetTime()
                    while t > time:
                        time += 1
                        engine.ticks += 1
                    time = ika.GetTime()
                    engine.update_time()

                    self.draw_menu()
                    self.draw_options(optselected)

                    #ika.Video.Blit(self.select2, 14, 46 + 12 * optselected) #ugly rectangle.
                    ika.Video.DrawRect(17, 59 + 12 * optselected, 100, 67+12*optselected, ika.RGB(100,255,100,128),1)

                    ika.Video.ShowPage()
                    ika.Input.Update()


                    if len(ika.Input.joysticks) > 0 and controls.usejoystick==True: #poll for gamepad buttons
                        newKey = None
                        newString = ''
                        #for i in range(len(ika.Input.joysticks[0].axes)):
                        #    if (abs(ika.Input.joysticks[0].axes[i].Position())
                        #        > controls.deadzone):
                        #        newKey = ika.Input.joysticks[0].axes[i]
                        #        newString = 'JOYAXIS%i %s' % (i, '-+'[ika.Input.joysticks[0].axes[i].Position() > 0])
                        #        break
                        for i in range(len(ika.Input.joysticks[0].buttons)):
                            if ika.Input.joysticks[0].buttons[i].Pressed():
                                newKey = ika.Input.joysticks[0].buttons[i]
                                controls.control_list[self.configkeys[optselected]].buttons['joy'].Set('joy:0:buttons:'+str(i))
                                done=True
                                break





                    #check keyboard buttons
                    for keyName in controls.controlnames:
                        k = ika.Input.keyboard[keyName]
                        if k.Pressed(): #key pressed!

                            #so much happening in one line of code!
                            controls.control_list[self.configkeys[optselected]].buttons['key'].Set('key:'+keyName)
                            done=True