예제 #1
0
    def select_skin(self, path):
        x = SoundThread("shotClick.wav")
        x.start()

        JsonConnector.save_key_to_config("skin", path)
        self.centralwidget.close()
        self.load_skins()
        self.core.window.resize_tlo()
        self.centralwidget.show()
예제 #2
0
    def select_skill(self, index_):
        x = SoundThread("shotClick.wav")
        x.start()

        self.skill_list[index_]["selected"] = True
        JsonConnector.save_skills_dict(self.skill_list)

        self.load_skill_to_config(self.skill_list[index_]["name"])

        self.centralwidget.close()
        self.load_skills()
        self.core.window.resize_tlo()
        self.centralwidget.show()
예제 #3
0
 def load_player_config(self):
     config = JsonConnector.get_from_config("shipConfig")
     self.laser_penetrate = config["penetrate"]
     self.ship_size = config["shipSize"]
     self.fire_speed = config["fireSpeed"]
     self.ammo_size = config["ammoSize"]
     self.ammo_dist = config["ammoSpeed"]
예제 #4
0
    def make_skin_card(self, skin_info, index_in_skin_list):
        sclabel = QtWidgets.QLabel(self.scrollAreaWidgetContents)
        sclabel.setGeometry(QtCore.QRect(200, 0, 100, 100))
        sclabel.setText(skin_info["name"])
        sclabel.setFont(self.clfont)
        sclabel.setPalette(self.clpalette)
        self.label_list.append(sclabel)

        scimage = QtWidgets.QLabel(self.scrollAreaWidgetContents)
        scimage.setText("")
        scimage.setScaledContents(True)
        scimage.setGeometry(QtCore.QRect(200, 200, 100, 100))
        scimage.setPixmap(
            QtGui.QPixmap("images/skins/" + skin_info["path"] +
                          ".png"))  # images/skins/benek.png
        self.image_list.append(scimage)

        scbutton = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
        scbutton.setGeometry(QtCore.QRect(200, 400, 100, 100))
        if skin_info["available"]:
            if JsonConnector.get_from_config("skin") == skin_info["path"]:
                scbutton.setText("Selected")
            else:
                scbutton.setText("Select")
                scbutton.clicked.connect(
                    lambda: self.select_skin(skin_info["path"]))
        else:
            scbutton.setText("Buy by " + str(skin_info["price"]) + " coins")
            scbutton.clicked.connect(
                lambda: self.buy_skin(index_in_skin_list, scbutton))

        self.customize_btn(scbutton)
        self.btn_list.append(scbutton)
예제 #5
0
    def __init__(self, layout, move_distance=100, *args):
        super().__init__(layout, *args)
        self.clocks = []

        self.load_player_config()

        self.set_player_geo()
        self.setText("")
        self.setPixmap(QtGui.QPixmap("images/skins/" + JsonConnector.get_from_config("skin") + ".png"))
        self.setScaledContents(True)        # odpowiada za pozwolenie na skalowanie grafik

        self.move_distance = self.okno.gWidth / move_distance
        self.can_shot = True

        self.playing_sound = False

        self.rtimer = QTimer()
        self.clocks.append(self.rtimer)
        self.rtimer.timeout.connect(self.ruch_prawo)
        self.ltimer = QTimer()
        self.clocks.append(self.ltimer)
        self.ltimer.timeout.connect(self.ruch_lewo)

        self.shot_block_timer = QTimer()
        self.clocks.append(self.shot_block_timer)
        self.shot_block_timer.timeout.connect(self.shot_accuracy_unblock)

        self.make_move_animations()
        self.make_reload_bar()
예제 #6
0
    def buy_skill(self, skill_dict_index, btn_instance):
        coins = JsonConnector.get_from_config("coins")
        if coins >= self.skill_list[skill_dict_index]["price"]:
            self.skill_list[skill_dict_index]["available"] = True
            JsonConnector.save_skills_dict(self.skill_list)

            coins -= self.skill_list[skill_dict_index]["price"]
            JsonConnector.save_key_to_config("coins", coins)
            self.make_coin_label()

            x = SoundThread("shotFanfar.wav")
            x.start()

            self.centralwidget.close()
            self.load_skills()
            self.core.window.resize_tlo()
            self.centralwidget.show()
        else:
            self.can_not_buy_anim(btn_instance)
예제 #7
0
 def load_highscore(self, _translate):
     high = JsonConnector.get_from_config("highscore")
     self.menu_highscore.setText(
         _translate("MainWindow", "Highscore: " + str(high)))
     self.score.setText(
         _translate("MainWindow", "Score: " + str(Postac.score)))
     self.coin_label.setText(
         _translate("MainWindow", "Coins: " +
                    str(JsonConnector.get_from_config("coins"))))
     if Postac.score > high:
         self.menu_info.setText(
             _translate("MainWindow", "New Highscore !!!"))
     elif Postac.score > 15000:
         self.menu_info.setText(
             _translate("MainWindow", "You are magnificent !!!"))
     elif Postac.score > 10000:
         self.menu_info.setText(_translate("MainWindow", "Good Job !!"))
     elif Postac.score > 5000:
         self.menu_info.setText(_translate("MainWindow", "Nice !"))
예제 #8
0
    def load_skills(self):
        self.image_list = [
        ]  # tworzy liste z instancjami elementów karty skilla aby można było je resizować
        self.btn_list = []
        self.label_list = []

        self.load_card_elements(
        )  # ładuje gotowe właściwości do elementów scrolla
        self.set_scrollbar_pos_to_start(
        )  # ustala scroll na początek aby po ponownym załadowaniu jego pozycja była prawidłowa

        self.skill_list = JsonConnector.get_skills_dict()
        for ind, elem in enumerate(self.skill_list):
            self.make_skill_card(elem, ind)
예제 #9
0
    def open_chest(self):
        x = SoundThread("shotFanfar.wav")
        x.start()

        coins = Chest().open(Postac.score)
        self.coin_label.setText("Coins: " +
                                str(JsonConnector.get_from_config("coins")))
        self.chest_label.setText("Award: " + str(coins) + " coins")

        self.start_chest_anim()

        self.chest_btn.setParent(None)
        self.chest_btn.deleteLater()
        self.chest_btn = None
예제 #10
0
 def make_coin_label(self):
     self.coin_label = QtWidgets.QLabel(self.centralwidget)
     self.coin_label.setGeometry(QtCore.QRect(0, 0, 791, 81))
     palette = QtGui.QPalette()
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
     brush.setStyle(QtCore.Qt.SolidPattern)
     palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText,
                      brush)
     brush = QtGui.QBrush(QtGui.QColor(255, 255, 255))
     brush.setStyle(QtCore.Qt.SolidPattern)
     palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText,
                      brush)
     brush = QtGui.QBrush(QtGui.QColor(120, 120, 120))
     brush.setStyle(QtCore.Qt.SolidPattern)
     palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText,
                      brush)
     self.coin_label.setPalette(palette)
     font = QtGui.QFont()
     font.setPointSize(26)
     self.coin_label.setFont(font)
     self.coin_label.setAlignment(QtCore.Qt.AlignCenter)
     self.coin_label.setText("Coins: " +
                             str(JsonConnector.get_from_config("coins")))
예제 #11
0
 def load_skill_to_config(skill_name, select=True):
     if select:
         if skill_name == "BiggerAmmo":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["ammoSize"] = [40, 12]
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "FasterAmmo":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["ammoSpeed"] = 16
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "SmallerShip":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["shipSize"] = 20
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "MoreFireRate":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["fireSpeed"] = 600
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "LaserPenetrate":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["penetrate"] = True
             JsonConnector.save_key_to_config("shipConfig", conf)
     else:
         if skill_name == "BiggerAmmo":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["ammoSize"] = [80, 20]
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "FasterAmmo":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["ammoSpeed"] = 23
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "SmallerShip":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["shipSize"] = 15
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "MoreFireRate":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["fireSpeed"] = 900
             JsonConnector.save_key_to_config("shipConfig", conf)
         elif skill_name == "LaserPenetrate":
             conf = JsonConnector.get_from_config("shipConfig")
             conf["penetrate"] = False
             JsonConnector.save_key_to_config("shipConfig", conf)
예제 #12
0
파일: game_core.py 프로젝트: syurskyi/QT
 def check_score(self):
     x = JsonConnector.get_from_config("highscore")
     if x < Postac.score:
         JsonConnector.save_key_to_config("highscore", Postac.score)
예제 #13
0
 def load_highscore(self, _translate):
     self.menu_highscore.setText(
         _translate(
             "MainWindow", "Highscore: " +
             str(JsonConnector.get_from_config("highscore"))))