Exemple #1
0
    def mapscreen(self):
        time = ika.GetTime()
        ika.Input.Unpress()
        ika.Input.Update()
        scrolltime = 0
        while not (controls.cancel.Pressed() or controls.confirm.Pressed()):
            t = ika.GetTime()
            while t > time:
                time += 1
                engine.ticks += 1
                if scrolltime > 0:
                    scrolltime -= 1
            engine.update_time()
            self.draw_menu()
            print >> fonts.two(160, 30, align='center'), self.mapname
            engine.automap.draw_automap(self.mapx, self.mapy)
            c1 = ika.RGB(0, 200, 255, 200)
            c2 = ika.RGB(200, 200, 255, 200)

            #scroll triangles
            if self.mapx > 0:
                ika.Video.DrawTriangle((10, 100, c1), (20, 90, c2),
                                       (20, 110, c2))
            if self.mapx + 37 < 50:
                ika.Video.DrawTriangle((310, 100, c1), (300, 90, c2),
                                       (300, 110, c2))
            if self.mapy > 0:
                ika.Video.DrawTriangle((160, 40, c1), (150, 50, c2),
                                       (170, 50, c2))
            if self.mapy + 23 < 50:
                ika.Video.DrawTriangle((160, 185, c1), (150, 175, c2),
                                       (170, 175, c2))
            ika.Video.ShowPage()
            ika.Input.Update()
            if scrolltime == 0:
                if controls.right.Position() > controls.deadzone and self.mapx + 37 < 50:
                    self.mapx += 1
                    scrolltime = 5
                elif controls.left.Position() > controls.deadzone and self.mapx > 0:
                    self.mapx -= 1
                    scrolltime = 5
                elif controls.down.Position() > controls.deadzone and self.mapy + 23 < 50:
                    self.mapy += 1
                    scrolltime = 5
                elif controls.up.Position() > controls.deadzone and self.mapy > 0:
                    self.mapy -= 1
                    scrolltime = 5
Exemple #2
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')
Exemple #3
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