Beispiel #1
0
    def __init__(self):
        DefaultView.__init__(self)

        path = bge.logic.expandPath("//")

        self.bgImage = bgui.Image(self, "bgImage", img=path+"textures/bg.JPG", size=[1, 1])

        bgui.Label(self.bgImage, "mainLabel", pos=[0.4, 0.5], text="Highscore!  ", pt_size=self.ptGross,
            options=bgui.BGUI_DEFAULT)
        bgui.Label(self.bgImage, "cLabel", pos=[0, 0], text="(c) 2013, capgeti, v0.9", pt_size=self.ptKlein)

        self.gameMenu = bgui.Frame(self.bgImage, "gameMenu", size=[0.3, 0.7], pos=[0.02, 0.15], border=1)

        self.backButton = bgui.FrameButton(self.gameMenu, 'backButton', text='Zurück', pt_size=self.ptNormal,
            size=[0.7, 0.1], pos=[0.3, 0.75], options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
        self.backButton.on_click = self.forBack

        bge.logic.loadGlobalDict()

        if not "highScore" in bge.logic.globalDict:
            bge.logic.globalDict['highScore'] = list()

        scores = bge.logic.globalDict['highScore']
        if not scores:
            return

        scores.sort(key=lambda tup: tup[1])
        scores.reverse()

        for i, score in enumerate(scores):
            wer = str(i+1) + ") " + score[0] + ": " + str(score[1])
            bgui.Label(self.bgImage, "highScore" + str(i), text=wer, pt_size=self.ptNormal-13, pos=[0.1, 0.6 - (i * 0.05)])
Beispiel #2
0
    def main(self):
        DefaultView.main(self)

        if playerController.player["isTot"]:
            if not self.gameOver.visible:
                self.gameOver.visible = True
                self.gameOverPunktestand.text = "Punkte: " + str(playerController.player["points"])
                self.gameOverNameBox.activate()
            return

        weapons = playerController.player["weapons"]

        # HP View
        self.hpAnzeige.text = str(playerController.player["hp"])

        # Points View
        self.points.text = str(playerController.player["points"])

        # Wave View
        self.waveEnemiesRest.text = str(len(waveController.currentEnemies))
        self.waveNumber.text = str(waveController.waveCounter)

        if waveController.spawnTimer:
            self.waveTitle.visible = True
            self.waveTitle.text = "Nächste Welle in: " + str(waveController.spawnTimer)
        else:
            self.waveTitle.visible = False

        # Weapon View
        currentWeapon = playerController.player["currentWeapon"]
        if currentWeapon:
            self.weaponNameLabel.text = currentWeapon.name
            self.muniLabel.text = str(currentWeapon.schuss).zfill(2) + " / " + str(currentWeapon.schusskapa).zfill(2)
            self.magazinLabel.text = str(currentWeapon.magazine).zfill(2)
        else:
            self.muniLabel.text = "- / -"
            self.weaponNameLabel.text = "Keine Waffe"
            self.magazinLabel.text = "-"

        for i in range(self.itemcount):
            item = self.items[i].itemImage
            itemImage = item.image
            if weapons[i]:
                path = rootPath + "textures/" + weapons[i].objName + ".png"
                if itemImage != path:
                    item.visible = True
                    item.update_image(path)
            elif item.image:
                item.visible = False
                item.image = None
Beispiel #3
0
    def update_keyboard(self, key, is_shifted):
        DefaultView.update_keyboard(self, key, is_shifted)

        if playerController.player["isTot"]:
            pass
        else:
            if key == 218:  # ESC
                self.gameMenu.visible = not self.gameMenu.visible

            for i in range(self.itemcount):
                if key == str(i + 1):
                    self.selectItem(self.items[i])

            if key == "q":
                playerController.dropCurrentWeapon()
Beispiel #4
0
    def __init__(self):
        DefaultView.__init__(self)

        width = bge.render.getWindowWidth()
        height = bge.render.getWindowHeight()

        aspect = width / height

        self.itemcount = 3
        self.items = []

        self.createHPView(aspect)
        self.createPointView(aspect)
        self.createWaveView(aspect)
        self.createMunintionView(aspect)
        self.createItemList(aspect)
        self.createMainMenu()

        # Game Over Label
        self.gameOver = bgui.Frame(self, "gameOver", size=[0.4, 0.7], pos=[0.35, 0.15], border=1)

        self.gameOverLabel = bgui.Label(
            self.gameOver, "gameOverLabel", text="Game Over!", pt_size=self.ptSehrGross, pos=[0.1, 0.83]
        )
        self.gameOverPunktestand = bgui.Label(
            self.gameOver, "gameOverPunktestand", text="Punkte:", pt_size=self.ptGross, pos=[0.1, 0.67]
        )

        self.gameOverNameLabel = bgui.Label(
            self.gameOver,
            "gameOverNameLabel",
            text="Bitte gib deinen Namen ein:",
            pt_size=self.ptNormal,
            pos=[0.1, 0.55],
        )

        self.gameOverSaveButton = bgui.FrameButton(
            self.gameOver, "saveButton", text="Eintragen", pt_size=self.ptNormal, size=[0.4, 0.1], pos=[0.05, 0.05]
        )
        self.gameOverSaveButton.on_click = self.savePoints

        self.gameOverCancelButton = bgui.FrameButton(
            self.gameOver,
            "gameOverCancelButton",
            text="Hauptmenü",
            pt_size=self.ptNormal,
            size=[0.4, 0.1],
            pos=[0.55, 0.05],
        )
        self.gameOverCancelButton.on_click = self.showMainMenu

        self.gameOverNameBox = bgui.TextInput(
            self.gameOver,
            "gameOverNameBox",
            text="<Name>",
            pt_size=self.ptNormal,
            pos=[0.1, 0.4],
            size=[0.8, 0.1],
            input_options=bgui.BGUI_INPUT_SELECT_ALL,
        )

        self.gameOver.visible = False
        print("init")