class GifPlayer(QWidget):
    def __init__(self, title, gifFile):
        super().__init__(self)
        self.setWindowTitle(title)

        self.movie = QMovie(gifFile, QByteArray(), self)

        size = self.movie.scaledSize()
        self.setGeometry(200, 200, size.width(), size.height())

        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.movie_screen.setAlignment(Qt.AlignCenter)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.movie_screen)
        self.setLayout(main_layout)

        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

        button = QPushButton('refresh gif', self)
        button.setToolTip('This is an example button')
        button.move(10,10)
        button.clicked.connect(self.on_click)

    @pyqtSlot()
    def on_click(self):
        self.movie = QMovie(gifFile,QByteArray(), self)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        print("done")
Beispiel #2
0
class Ui_MainWindow(object):
    okno = None

    def __init__(self):
        self.tlo = QtWidgets.QLabel(
        )  # atrapy elementów tak aby nie powstawały błędy
        self.player = QtWidgets.QLabel()
        self.enemy = QtWidgets.QLabel()
        self.score = QtWidgets.QLabel()

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
        self.centralwidget.setObjectName("centralwidget")

        self.make_background()
        self.make_score()
        self.player = Benek(self.centralwidget)
        self.centralwidget.close()

        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.score.setText(_translate("MainWindow", "Score: 0"))

    def make_background(self):
        self.tlo = QtWidgets.QLabel(self.centralwidget)
        self.tlo.setGeometry(
            QtCore.QRect(0, 0, self.okno.width(), self.okno.height()))
        self.tlo.setText("")
        self.tlo.setPixmap(QtGui.QPixmap("images/stars_background.gif"))
        self.tlo.setScaledContents(True)
        self.tlo.setObjectName("label")

        self.movie = QMovie("images/stars_background.gif", QByteArray(),
                            self.tlo)
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie.setSpeed(100)
        self.tlo.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

    def make_score(self):
        Postac.score = 0
        self.score = QtWidgets.QLabel(self.centralwidget)
        self.score.setGeometry(QtCore.QRect(0, 100, 261, 41))
        font = QtGui.QFont()
        font.setPointSize(24)
        font.setBold(True)
        self.score.setFont(font)
        self.score.setText("Score: 0")
        self.score.setObjectName("label_4")
        self.score.setStyleSheet("QLabel#label_4 {color: #aaffff}")
class GifPlayer2(QWidget):
    def __init__(self, title, gifFile):
        self.movie = QMovie(gifFile, QByteArray(), self)
        size = self.movie.scaledSize()
        self.setGeometry(200, 200, size.width(), size.height())
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()
Beispiel #4
0
class GifPlayer(QWidget):
    def __init__(self, name, parent=None):
        QWidget.__init__(self, parent)

        self.movie = QMovie(name, QByteArray(), self)
        size = self.movie.scaledSize()
        self.setGeometry(0, 0, size.width(), size.height())
        self.im = Image.open(name).size
        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
        self.movie_screen.setAlignment(Qt.AlignCenter)
        main_layout = QVBoxLayout()
        main_layout.addWidget(self.movie_screen)
        self.setLayout(main_layout)
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

        self.btn_s = QPushButton('Scale', self)
        self.btn_s.resize(80, 25)
        self.btn_s.move(0, 460)
        self.btn_s.clicked.connect(self.resizeGIF)
        self.btn_s.setStyleSheet("""
    QPushButton:hover { background-color: red; color: white }
    QPushButton:!hover { background-color: rgb(105, 105, 105); color: white }
    QPushButton:pressed { background-color: rgb(205, 92, 92); color: white }
""")

    # Этот метод меняет разрешение гиф-анимации в окне result
    def resizeGIF(self):
        try:
            rect = self.geometry()
            w = rect.width()
            h = rect.height()
            w1, h1 = self.im
            if w > 20 and h > 20:
                w -= 20
                h -= 20
            k = h1 / h
            w = w1 / k
            size = QtCore.QSize(int(w), h)

            movie = self.movie_screen.movie()
            movie.setScaledSize(size)
        except Exception as er:
            print(er)
class Canvas(QWidget):
    def __init__(self):
        super().__init__()
        self.image = QImage()
        self.movie = QMovie()

    def play_gif(self, gif_url):
        self.movie = QMovie(gif_url, QByteArray(), self)
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie.start()
        self.movie.loopCount()

    def paintEvent(self, event):
        qp = QPainter(self)
        if not self.image.isNull():
            image = self.image.scaled(self.size())
            qp.drawImage(0, 0, image)
Beispiel #6
0
class Loading(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.setup_ui()

    def setup_ui(self):
        self.movie = QMovie('assets\\load.gif')
        gu = ctypes.windll.user32
        self.setWindowFlags(Qt.FramelessWindowHint)

        if int(open('Assets\\scaling.txt', mode='r').read()) == 0:
            # self.setGeometry(gu.GetSystemMetrics(0) / 2 - 300 / 2, gu.GetSystemMetrics(1) / 2 - 300 / 2, 300, 300)
            self.setGeometry(
                QtCore.QRect(
                    gu.GetSystemMetrics(0) / 2 - 300 / 2,
                    gu.GetSystemMetrics(1) / 2 - 300 / 2, 300, 300))
        else:
            self.setGeometry(500, 500, 300, 300)

        self.lbl = QLabel()
        self.setStyleSheet("QLabel\n"
                           "{\n"
                           "     background-color: #D7CCC8;\n"
                           "}\n")
        self.lbl.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.lbl.setAlignment(Qt.AlignCenter)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.lbl)
        self.setLayout(main_layout)
        self.movie.setCacheMode(QMovie.CacheAll)
        self.lbl.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

    def start_dialog(self):
        self.setWindowFlags(Qt.WindowStaysOnTopHint)
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.show()

    def stop_dialog(self):
        self.hide()
Beispiel #7
0
class LoadingScreen(QDialog):
    def __init__(self, parent, file_path, text):
        """Initialise the loading screen
        
        Arguments:
            parent {QObject} -- The parent QObject
            file_path {str} -- Path to file of loading GIF
            text {str} -- Text to be shown on the loading screen
        """
        super().__init__(parent)
        self.file = file_path
        self.text = text
        self.setWindowFlag(Qt.FramelessWindowHint)
        self.setFixedSize(200, 200)
        self.setModal(True)
        self.init_UI()

    def init_UI(self):
        """Initialise the UI by loading the GIF and adding the text label
        """
        vbox = QVBoxLayout()
        vbox.setAlignment(Qt.AlignHCenter)
        self.movie_screen = QLabel(self)
        self.movie_screen.setFixedSize(50, 50)

        self.movie = QMovie(self.file, QByteArray(), self)
        self.movie.setScaledSize(self.movie_screen.size())
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie.setSpeed(100)
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

        self.loading = QLabel(self.text)
        self.loading.setAlignment(Qt.AlignCenter)
        vbox.addStretch(2)
        vbox.addWidget(self.movie_screen, Qt.AlignCenter)
        vbox.addSpacing(10)
        vbox.addWidget(self.loading, Qt.AlignHCenter)
        vbox.addStretch(1)
        self.setLayout(vbox)
Beispiel #8
0
class Load(QWidget):
    def __init__(self):
        super().__init__()
        self.movie = QMovie("load.gif", QByteArray(), self)
        size = self.size()
        screenGeometry = QDesktopWidget().screenGeometry(-1).size()
        self.setGeometry((screenGeometry.width() - size.width()) // 2,
                         (screenGeometry.height() - size.height()) // 2,
                         size.width(), size.height())
        self.setWindowTitle('')
        self.movie_screen = QLabel()
        self.movie_screen.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
        self.movie_screen.setAlignment(Qt.AlignCenter)
        main_layout = QVBoxLayout()
        main_layout.addWidget(self.movie_screen)
        self.setLayout(main_layout)
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie_screen.setMovie(self.movie)
        self.frame_count = self.movie.frameCount()
        self.movie.frameChanged.connect(self.frameChanged)
        self.frame = 0
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_NoSystemBackground, True)
        self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.movie.start()
        self.app = MainApp()
        self.movie.loopCount()

    def frameChanged(self):
        self.frame += 1
        if self.frame >= self.frame_count:
            self.movie.stop()
            self.movie.setParent(None)
            self.movie.deleteLater()
            self.setAttribute(Qt.WA_NoSystemBackground, False)
            self.setAttribute(Qt.WA_TranslucentBackground, False)
            self.destroy()
            self.app.show()
Beispiel #9
0
class Pomodoro():
    def __init__(self):
        self.timer = 0
        self.progress_value = 0
        self.running = False
        self.cycles = 0
        self.state = STATE.WORK
        self.beep = AudioSegment.from_mp3("pomodoro.mp3")

    def swap_state(self):
        if self.state == STATE.WORK:
            self.state = STATE.PAUSE
        else:
            self.state = STATE.WORK
            self.cycles += 1
            self.set_cycles()

    def swap(self):
        self.swap_state()
        self.state_label.setText(STATE_LABELS[self.state])
        self.timer = 0
        play(self.beep)

    def reset(self):
        self.timer = 0
        self.change_progress_bar()
        self.change_time_label()

    def toggle(self):
        if self.running:
            self.toggle_button.setText('Play')
            self.running = False
            self.loop_stopper.set()
            self.movie.stop()
        else:
            self.toggle_button.setText('Pause')
            self.running = True
            self.run()
            self.movie.start()

    def set_cycles(self):
        self.cycles_label.setText('{} cycles'.format(self.cycles))

    def run(self):
        self.loop_stopper = threading.Event()
        self.window.loop_stopper = self.loop_stopper
        self.loop = threading.Thread(target=self.clock_loop,
                                     args=(self.loop_stopper, ))
        self.loop.start()

    def change_progress_bar(self):
        new_progress_value = int(self.timer / CYCLE_LENGTHS[self.state] * 100)
        if new_progress_value != self.progress_value:
            self.progress_value = new_progress_value
            self.progress.setValue(self.progress_value)

    def change_time_label(self):
        mins = self.timer // 60
        secs = self.timer - mins * 60
        total_mins = CYCLE_LENGTHS[self.state] // 60
        total_secs = CYCLE_LENGTHS[self.state] - total_mins * 60
        new_time_label = "{:02d}:{:02d} / {:02d}:{:02d}".format(
            mins, secs, total_mins, total_secs)
        self.time_label.setText(new_time_label)

    def clock_loop(self, stopper):
        while not stopper.isSet():
            self.timer += 1
            self.change_progress_bar()
            self.change_time_label()
            if self.timer == CYCLE_LENGTHS[self.state]:
                self.swap()
            time.sleep(1)

    def exec(self):
        self.app = QApplication([])

        # button font
        button_font = QtGui.QFont("Sans", 13, QtGui.QFont.Bold)

        # toggle button
        self.toggle_button = QPushButton('Start')
        self.toggle_button.setCheckable(True)
        self.toggle_button.clicked.connect(self.toggle)
        self.toggle_button.setFont(button_font)

        # reset button
        self.reset_button = QPushButton('Reset')
        self.reset_button.clicked.connect(self.reset)
        self.reset_button.setFont(button_font)

        # progress label
        self.progress_label = QLabel()
        self.movie = QMovie("spinner.gif")
        self.progress_label.setMovie(self.movie)
        self.progress_label.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)
        self.progress_label.setAlignment(Qt.AlignCenter)

        # label
        self.label = QLabel('Pomodoro timer')
        self.pixmap = QPixmap('pomodoro.png')
        self.label.setPixmap(self.pixmap)

        # time label
        self.time_label = QLabel('00:00 / 25:00')
        self.time_label.setFont(button_font)

        # cycles label
        self.cycles_label = QLabel('0 cycles')
        cycles_font = QtGui.QFont("Sans", 12, QtGui.QFont.Bold)
        self.cycles_label.setFont(cycles_font)

        # state label
        state_font = QtGui.QFont("Sans", 18, QtGui.QFont.Bold)
        self.state_label = QLabel(STATE_LABELS[self.state])
        self.state_label.setFont(state_font)

        # progressbar
        self.progress = QProgressBar()
        self.progress.setMaximum(100)
        self.progress.setMinimum(0)
        self.progress.setValue(0)

        self.window = CloseableQWidget(self)
        self.window.setGeometry(770, 440, 400, 200)

        self.outer_vertical = QVBoxLayout()
        self.inner_horizonal = QHBoxLayout()
        self.buttons_vertical = QVBoxLayout()
        self.slider_clock_layout = QHBoxLayout()
        self.labels = QHBoxLayout()

        self.outer_vertical.addLayout(self.inner_horizonal)

        self.inner_horizonal.addWidget(self.label)
        self.inner_horizonal.addLayout(self.buttons_vertical)

        self.buttons_vertical.addWidget(self.toggle_button)
        self.buttons_vertical.addWidget(self.reset_button)

        self.slider_clock_layout.addWidget(self.progress)
        self.slider_clock_layout.addWidget(self.time_label)

        self.labels.addWidget(self.state_label)
        self.labels.addWidget(self.cycles_label)
        self.labels.addWidget(self.progress_label, alignment=Qt.AlignRight)
        self.outer_vertical.addLayout(self.labels)
        self.outer_vertical.addLayout(self.slider_clock_layout)

        self.window.setLayout(self.outer_vertical)
        self.window.show()

        # gif options
        self.movie.setCacheMode(QMovie.CacheAll)
        self.progress_label.setMovie(self.movie)
        self.movie.jumpToFrame(1)
        self.movie.loopCount()

        self.app.setStyle('Fusion')
        sys.exit(self.app.exec_())
Beispiel #10
0
class Board(QFrame):
    def __init__(self, playerOneName=None, playerTwoName=None, level=None):
        self.nameOne = playerOneName
        self.nameTwo = playerTwoName
        self.level = level

        super().__init__()

        self.setFixedSize(800, 600)

        self.queueLifeX = Queue()
        self.queueLifeY = Queue()
        self.process = Process(target=ForceLife,
                               args=[self.queueLifeX, self.queueLifeY])
        self.process.start()

        self.queueBombX = Queue()
        self.queueBombY = Queue()
        self.process2 = Process(target=ForceBomb,
                                args=[self.queueBombX, self.queueBombY])
        self.process2.start()

        self.PlatformChanged = 0

        self.moveRightFlags = 0
        self.moveLeftFlags = 0
        self.moveUpFlags = 0
        self.moveDownFlags = 0
        self.moveRight2Flags = 0
        self.moveLeft2Flags = 0
        self.moveUp2Flags = 0
        self.moveDown2Flags = 0
        self.cekanjePlayer1_1 = 0
        self.cekanjePlayer2_1 = 0
        self.cekanjePlayer1_2 = 0
        self.cekanjePlayer2_2 = 0
        self.movePlayerFlags = 0

        self.avatar1hitHeart = False
        self.avatar2hitHeart = False
        self.avatar1hitBomb = False
        self.avatar2hitBomb = False

        self.bombExist = False
        self.LifeExist = False

        self.hitWall = False
        self.barrels = []

        self.Lives1 = 3
        self.Lives2 = 3

        self.isLive1 = True
        self.isLive2 = True

        self.point1 = 0
        self.point2 = 0
        self.first = [True, False, False, False, False, False]
        self.second = [True, False, False, False, False, False]

        self.pamtiPrvog = 0
        self.pamtiDrugog = 0

        self.pobednik = 0

        self.initBoard()

        self.key_notifyer = KeyNotifyer()
        self.key_notifyer.key_signal.connect(self.__update_position__)
        self.key_notifyer.start()

        self.monkey_movement = MonkeyMovement(self.level)
        self.monkey_movement.move_monkey_signal.connect(self.moveMonkey)
        self.monkey_movement.start(1)

        self.barrel_movement = BarrelMovement(self.level)
        self.barrel_movement.move_barrel_signal.connect(self.moveBarrel)
        self.barrel_movement.start(1)

        self.points_counter = PointsCounter()
        self.points_counter.point_counter_signal.connect(self.refreshPoints)
        self.points_counter.start()

        self.unexpected_force_life = UnexpectedForceLife(self)
        self.unexpected_force_life.show_life_signal.connect(self.showLifeForce)
        self.unexpected_force_life.hide_life_signal.connect(self.hideLifeForce)
        self.unexpected_force_life.start()

        self.unexpected_force_bomb = UnexpectedForceBomb(self)
        self.unexpected_force_bomb.show_bomb_signal.connect(self.showBombForce)
        self.unexpected_force_bomb.hide_bomb_signal.connect(self.hideBombForce)
        self.unexpected_force_bomb.start()

        self.unexpected_force = UnexpectedForce()
        self.unexpected_force.mario1_signal.connect(self.executeForce)
        self.unexpected_force.mario2_signal.connect(self.executeForce2)
        self.unexpected_force.start()

        self.delayed_effect_of_force = DelayedEffectOfForce()
        self.delayed_effect_of_force.delayed_effect_of_force_signal.connect(
            self.checkCollisionWithUnexpectedForce)
        self.delayed_effect_of_force.start()

    def initBoard(self):
        self.resize(800, 600)
        self.center()
        self.setWindowTitle('Donkey Kong')

        self.setStyleSheet("QFrame { background-color: %s}" %
                           QColor(0, 0, 0).name())

        sirina = 800 / 54  # sirina kockice za ivicu
        visina = 600 / 40  #visina kocikice za ivicu

        brickImage = QPixmap('Assets/Brick/Brick.png')
        brickImageCropped = brickImage.scaled(sirina, visina,
                                              Qt.IgnoreAspectRatio,
                                              Qt.FastTransformation)

        self.BorderList = []

        for i in range(40):
            for j in range(54):
                if i == 0 or i == 39:
                    self.BorderList.append(
                        self.setBorder(brickImageCropped, i, j, sirina,
                                       visina))
                else:
                    if j == 0 or j == 53:
                        self.BorderList.append(
                            self.setBorder(brickImageCropped, i, j, sirina,
                                           visina))

        platformImage = QPixmap('Assets/Brick/Platforma.png')
        platformImageCropped = platformImage.scaled(20, 20,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.FastTransformation)

        platformRestImage = QPixmap('Assets/Brick/Platforma2.png')
        platformRestCroppedImage = platformRestImage.scaled(
            10, 20, Qt.IgnoreAspectRatio, Qt.FastTransformation)

        self.PlatformList = []

        for i in range(1, 6):
            for j in range(38):
                self.PlatformList.append(
                    self.setPlatform(platformImageCropped, i, j, sirina))

            self.PlatformList.append(
                self.setPlatform(platformRestCroppedImage, i, 38, sirina))

        self.setPrincess()
        self.playerName()
        self.setLadder()
        #self.setBarrel()
        self.setAvatars("Assets/Mario/marioR.png", "Assets/Mario/mario2L.png")
        self.setMonkey()

        self.show()

    def playerName(self):
        fontLbl = QFont()
        fontLbl.setFamily("Arcade Normal")
        fontLbl.setPointSize(8)

        if self.nameOne == "":
            self.nameOne = 'Player 1'

        if self.nameTwo == "":
            self.nameTwo = 'Player 2'

        self.levelLabel = QLabel(self)
        self.levelLabel.setText('Level ' + str(self.level))
        self.levelLabel.setFont(fontLbl)
        self.levelLabel.setStyleSheet("QLabel {color: white}")
        self.levelLabel.move(390, 20)

        self.playerOne = QLabel(self)
        self.playerOne.setText(self.nameOne)
        self.playerOne.setFont(fontLbl)
        self.playerOne.setStyleSheet("QLabel {color: red}")
        self.playerOne.move(30, 20)

        self.player1score = QLabel(self)
        self.player1score.setText('Score: ')
        self.player1score.setFont(fontLbl)
        self.player1score.setStyleSheet("QLabel {color: red}")
        #self.player1score.move(400, 40)
        self.player1score.setGeometry(30, 35, 100, 20)

        self.player1lives = QLabel(self)
        self.player1lives.setText('Lives: ' + str(self.Lives1))
        self.player1lives.setFont(fontLbl)
        self.player1lives.setStyleSheet("QLabel {color: red}")
        self.player1lives.move(30, 60)

        self.playerTwo = QLabel(self)
        self.playerTwo.setText(self.nameTwo)
        self.playerTwo.setFont(fontLbl)
        self.playerTwo.setStyleSheet("QLabel {color: green}")
        self.playerTwo.move(640, 20)

        self.player2score = QLabel(self)
        self.player2score.setText('Score: ')
        self.player2score.setFont(fontLbl)
        self.player2score.setStyleSheet("QLabel {color: green}")
        self.player2score.setGeometry(640, 35, 100, 20)
        #self.player2score.move(640, 40)

        self.player2lives = QLabel(self)
        self.player2lives.setText('Lives: ' + str(self.Lives1))
        self.player2lives.setFont(fontLbl)
        self.player2lives.setStyleSheet("QLabel {color: green}")
        self.player2lives.move(640, 60)

    def setBorder(self, pixmapCropped, i, j, sirina, visina):
        label = QLabel(self)
        label.setPixmap(QPixmap(pixmapCropped))
        label.move(j * sirina, i * visina)
        return label

    def setPlatform(self, platformImageCropped, i, j, sirina):
        label = QLabel(self)
        label.setPixmap(QPixmap(platformImageCropped))

        if i < 5:
            label.move(sirina + j * 20, 600 - i * 90 - 15)
        else:
            if j > 14 and j < 24:
                label.move(sirina + j * 20, 600 - i * 90 - 15)
            else:
                label.move(800, 600)

        label.show()

        return label

    def setPrincess(self):
        self.movie = QMovie("Assets/Princess/Princess.gif", QByteArray(), self)
        self.princessLabel = QLabel(self)
        self.princessLabel.setGeometry(383, 95, 80, 40)
        self.movie.setCacheMode(QMovie.CacheAll)
        self.princessLabel.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

    def setLadder(self):
        ladderImage = QPixmap('Assets/Ladder/ladder.png')
        ladderImageCropped = ladderImage.scaled(30, 70, Qt.IgnoreAspectRatio,
                                                Qt.FastTransformation)

        ladderImage1 = QPixmap('Assets/Ladder/ladder2.png')
        ladderImage2Cropped = ladderImage1.scaled(30, 70, Qt.IgnoreAspectRatio,
                                                  Qt.FastTransformation)

        brokenLadderImage = QPixmap('Assets/Ladder/brokenLadder.png')
        brokenLadderImageCropped = brokenLadderImage.scaled(
            30, 70, Qt.IgnoreAspectRatio, Qt.FastTransformation)

        # Merdevine na prvoj platformi
        self.brokenLadderPosition(brokenLadderImageCropped, 75, 515)
        self.ladderPosition(ladderImageCropped, 350, 515)
        self.ladderPosition(ladderImageCropped, 420, 515)
        self.brokenLadderPosition(brokenLadderImageCropped, 695, 515)

        # Merdevine na drugoj platformi
        self.ladderPosition(ladderImageCropped, 45, 425)
        self.brokenLadderPosition(brokenLadderImageCropped, 320, 425)
        self.brokenLadderPosition(brokenLadderImageCropped, 452, 425)
        self.ladderPosition(ladderImageCropped, 725, 425)

        # Merdevine na trecoj platformi
        self.brokenLadderPosition(brokenLadderImageCropped, 75, 335)
        self.ladderPosition(ladderImageCropped, 350, 335)
        self.ladderPosition(ladderImageCropped, 420, 335)
        self.brokenLadderPosition(brokenLadderImageCropped, 695, 335)

        # Merdevine na cetvrtoj platformi
        self.ladderPosition(ladderImageCropped, 45, 245)
        self.brokenLadderPosition(brokenLadderImageCropped, 320, 245)
        self.brokenLadderPosition(brokenLadderImageCropped, 452, 245)
        self.ladderPosition(ladderImageCropped, 725, 245)

        # Merdevine na petoj platformi
        '''self.ladderPosition(ladderImageCropped, 382, 155)
        self.ladderPosition(ladderImageCropped, 241, 155)
        self.ladderPosition(ladderImage2Cropped, 241, 85)
        self.ladderPosition(ladderImage2Cropped, 241, 15)
        self.ladderPosition(ladderImageCropped, 191, 155)
        self.ladderPosition(ladderImage2Cropped, 191, 85)
        self.ladderPosition(ladderImage2Cropped, 191, 15)'''
        self.ladderPosition(ladderImageCropped, 320, 155)
        self.ladderPosition(ladderImageCropped, 452, 155)

    def ladderPosition(self, ladderImageCropped, x, y):
        self.ladderlabel = QLabel(self)
        self.ladderlabel.setPixmap(QPixmap(ladderImageCropped))
        self.ladderlabel.move(x, y)  # x=685, y=515

    def brokenLadderPosition(self, brokenLadderImageCropped, x, y):
        self.brokenLadderlabel = QLabel(self)
        self.brokenLadderlabel.setPixmap(QPixmap(brokenLadderImageCropped))
        self.brokenLadderlabel.move(x, y)  # x=350, y=515

    def setAvatars(self, naziv, naziv2):
        ''' Avatar 1 '''

        self.avatarLable = QLabel(self)
        avatarImage = QPixmap(naziv)
        self.avatarLable.setStyleSheet(
            'QLabel { background-color: transparent }')
        avatarImageCropped = avatarImage.scaled(30, 40, Qt.IgnoreAspectRatio,
                                                Qt.FastTransformation)
        self.avatarLable.setPixmap(QPixmap(avatarImageCropped))
        self.avatarLable.move(40, 545)
        ''' Avatar 2 '''

        self.avatarLable2 = QLabel(self)
        avatarImage2 = QPixmap(naziv2)
        self.avatarLable2.setStyleSheet(
            'QLabel { background-color: transparent }')
        avatarImageCropped2 = avatarImage2.scaled(30, 40, Qt.IgnoreAspectRatio,
                                                  Qt.FastTransformation)
        self.avatarLable2.setPixmap(QPixmap(avatarImageCropped2))
        self.avatarLable2.move(720, 545)

    def setMonkey(self):
        self.monkeyLabel = QLabel(self)
        monkeyImage = QPixmap("Assets/Monkey/monkey.png")
        monkeyCroppedImage = monkeyImage.scaled(60, 70, Qt.IgnoreAspectRatio,
                                                Qt.FastTransformation)
        self.monkeyLabel.setStyleSheet(
            'QLabel { background-color: transparent }')
        self.monkeyLabel.setPixmap(QPixmap(monkeyCroppedImage))
        self.monkeyLabel.move(375, 155)

        self.manjiRand = random.randrange(20, 375)
        self.veciRand = random.randrange(self.manjiRand, 720)

    def moveMonkey(self):
        rect = self.monkeyLabel.geometry()

        rand = random.randrange(self.manjiRand, self.veciRand)

        if rand % 50 == 0:
            barrel = QLabel(self)
            barrelImage = QPixmap("Assets/Barrel/burrelBrown.png")
            barrelCroppedImage = barrelImage.scaled(28, 18,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.FastTransformation)
            barrel.setStyleSheet('QLabel { background-color: transparent }')
            barrel.setPixmap(QPixmap(barrelCroppedImage))
            barrel.move(rect.x(), rect.y() + 20)
            self.barrels.append(barrel)
            self.barrels[len(self.barrels) - 1].show()

        if self.hitWall:
            if rect.x() >= self.veciRand:
                self.hitWall = False
                self.manjiRand = random.randrange(20, self.veciRand)
            else:
                self.monkeyLabel.move(rect.x() + 5, rect.y())
        else:
            if rect.x() <= self.manjiRand:
                self.hitWall = True
                self.veciRand = random.randrange(self.manjiRand, 720)
            else:
                self.monkeyLabel.move(rect.x() - 5, rect.y())

        if self.isHit(self.monkeyLabel, self.avatarLable) and self.isLive1:
            print('Sudaaar')
            self.Lives1 = self.Lives1 - 1
            self.player1lives.setText('Lives: ' + str(self.Lives1))
            if (self.Lives1 > 0):
                self.avatarLable.move(40, 545)
            else:
                self.isLive1 = False
                self.avatarLable.clear()
                self.avatarLable.move(1000, 1000)
        elif self.isHit(self.monkeyLabel, self.avatarLable2) and self.isLive2:
            print('Sudaaar')
            self.Lives2 = self.Lives2 - 1
            self.player2lives.setText('Lives: ' + str(self.Lives2))
            if (self.Lives2 > 0):
                self.avatarLable2.move(720, 545)
            else:
                self.isLive2 = False
                self.avatarLable2.clear()
                self.avatarLable2.move(1100, 1100)
        self.isGameOver()

    def moveBarrel(self):

        for barrel in self.barrels:
            rect = barrel.geometry()
            barrel.move(rect.x(), rect.y() + 4)

            if self.isHit(barrel, self.avatarLable) and self.isLive1:
                print('Sudaaar')
                self.Lives1 = self.Lives1 - 1
                self.player1lives.setText('Lives: ' + str(self.Lives1))
                #barrel.move(0,0)
                barrel.hide()
                self.barrels.remove(barrel)
                if (self.Lives1 > 0):
                    self.avatarLable.move(40, 545)
                else:
                    self.isLive1 = False
                    self.avatarLable.clear()
                    self.avatarLable.move(1000, 1000)
            elif self.isHit(barrel, self.avatarLable2) and self.isLive2:
                print('Sudaaar')
                self.Lives2 = self.Lives2 - 1
                self.player2lives.setText('Lives: ' + str(self.Lives2))
                #barrel.move(0,0)
                barrel.hide()
                self.barrels.remove(barrel)
                if (self.Lives2 > 0):
                    self.avatarLable2.move(720, 545)
                else:
                    self.isLive2 = False
                    self.avatarLable2.clear()
                    self.avatarLable2.move(1100, 1100)
        self.isGameOver()

    def isHit(self, first, second):
        rec1 = first.geometry()
        y1 = first.height()
        x1 = first.width()
        rec2 = second.geometry()
        x2 = second.width()
        y2 = second.height()
        if rec1.x() + x1 in range(rec2.x(), rec2.x() + x2):
            if rec1.y() in range(rec2.y(), rec2.y() + y2):
                return True
            elif rec1.y() + y1 in range(rec2.y(), rec2.y() + y2):
                return True

        if rec1.x() in range(rec2.x(), rec2.x() + x2):
            if rec1.y() in range(rec2.y(), rec2.y() + y2):
                return True
            elif rec1.y() + y1 in range(rec2.y(), rec2.y() + y2):
                return True

        if rec2.x() + x2 in range(rec1.x(), rec1.x() + x1):
            if rec2.y() in range(rec1.y(), rec1.y() + y1):
                return True
            elif rec2.y() + y2 in range(rec1.y(), rec1.y() + y1):
                return True

        if rec2.x() in range(rec1.x(), rec1.x() + x1):
            if rec2.y() in range(rec1.y(), rec1.y() + y1):
                return True
            elif rec2.y() + y2 in range(rec1.y(), rec1.y() + y1):
                return True

    def setAttackBarrel(self):
        self.attackBurrel = QLabel(self)
        attackBurrelImage = QPixmap("Assets/Barrel/burrelBrown.png")
        attackBurrelCroppedImage = attackBurrelImage.scaled(
            28, 18, Qt.IgnoreAspectRatio, Qt.FastTransformation)
        self.attackBurrel.setStyleSheet(
            'QLabel { background-color: transparent }')
        self.attackBurrel.setPixmap(QPixmap(attackBurrelCroppedImage))
        self.attackBurrel.move(385, 245)

    def keyPressEvent(self, event):
        self.key_notifyer.add_key(event.key())

    def keyReleaseEvent(self, event):
        self.key_notifyer.remove_key(event.key())

    def __update_position__(self, key):
        rect = self.avatarLable.geometry()
        rect2 = self.avatarLable2.geometry()

        if key == Qt.Key_Right and self.isLive1:
            if rect.x() < 755:
                if rect.y() == 545 or rect.y() == 455 or rect.y(
                ) == 365 or rect.y() == 275 or rect.y() == 185:
                    self.movePlayerFlags = 1
                    self.moveRight()
        elif key == Qt.Key_Left and self.isLive1:
            if rect.x() > 20:
                if rect.y() == 545 or rect.y() == 455 or rect.y(
                ) == 365 or rect.y() == 275 or rect.y() == 185:
                    self.movePlayerFlags = 1
                    self.moveLeft()
        elif key == Qt.Key_Up and self.isLive1:
            if rect.y() <= 545 and rect.y() > 455 or rect.y(
            ) <= 365 and rect.y() > 275:
                if rect.x() == 72 or rect.x() == 352 or rect.x(
                ) == 424 or rect.x() == 696:
                    self.movePlayerFlags = 1
                    self.moveUp()
            elif rect.y() <= 455 and rect.y() > 365 or rect.y(
            ) <= 275 and rect.y() > 185:
                if rect.x() == 48 or rect.x() == 320 or rect.x(
                ) == 456 or rect.x() == 728:
                    self.movePlayerFlags = 1
                    self.moveUp()
            elif rect.y() <= 185 and rect.y() > 95:
                if rect.x() == 320 or rect.x() == 456:
                    self.movePlayerFlags = 1
                    self.moveUp()
        elif key == Qt.Key_Down and self.isLive1:
            if rect.y() < 545 and rect.y() >= 455 or rect.y() < 365 and rect.y(
            ) >= 275:
                if rect.x() == 72 or rect.x() == 352 or rect.x(
                ) == 424 or rect.x() == 696:
                    self.movePlayerFlags = 1
                    self.moveDown()
            elif rect.y() < 455 and rect.y() >= 365 or rect.y(
            ) < 275 and rect.y() >= 185:
                if rect.x() == 48 or rect.x() == 320 or rect.x(
                ) == 456 or rect.x() == 728:
                    self.movePlayerFlags = 1
                    self.moveDown()
            elif rect.y() < 185 and rect.y() >= 95:
                if rect.x() == 320 or rect.x() == 456:
                    self.movePlayerFlags = 1
                    self.moveDown()
        elif key == Qt.Key_A and self.isLive2:
            if rect2.x() > 20:
                if rect2.y() == 545 or rect2.y() == 455 or rect2.y(
                ) == 365 or rect2.y() == 275 or rect2.y() == 185:
                    self.movePlayerFlags = 2
                    self.moveLeft()
        elif key == Qt.Key_D and self.isLive2:
            if rect2.x() < 755:
                if rect2.y() == 545 or rect2.y() == 455 or rect2.y(
                ) == 365 or rect2.y() == 275 or rect2.y() == 185:
                    self.movePlayerFlags = 2
                    self.moveRight()
        elif key == Qt.Key_W and self.isLive2:
            if rect2.y() <= 545 and rect2.y() > 455 or rect2.y(
            ) <= 365 and rect2.y() > 275:
                if rect2.x() == 72 or rect2.x() == 352 or rect2.x(
                ) == 424 or rect2.x() == 696:
                    self.movePlayerFlags = 2
                    self.moveUp()
            elif rect2.y() <= 455 and rect2.y() > 365 or rect2.y(
            ) <= 275 and rect2.y() > 185:
                if rect2.x() == 48 or rect2.x() == 320 or rect2.x(
                ) == 456 or rect2.x() == 728:
                    self.movePlayerFlags = 2
                    self.moveUp()
            elif rect2.y() <= 185 and rect2.y() > 95:
                if rect2.x() == 320 or rect2.x() == 456:
                    self.movePlayerFlags = 2
                    self.moveUp()
        elif key == Qt.Key_S and self.isLive2:
            if rect2.y() < 545 and rect2.y() >= 455 or rect2.y(
            ) < 365 and rect2.y() >= 275:
                if rect2.x() == 72 or rect2.x() == 352 or rect2.x(
                ) == 424 or rect2.x() == 696:
                    self.movePlayerFlags = 2
                    self.moveDown()
            elif rect2.y() < 455 and rect2.y() >= 365 or rect2.y(
            ) < 275 and rect2.y() >= 185:
                if rect2.x() == 48 or rect2.x() == 320 or rect2.x(
                ) == 456 or rect2.x() == 728:
                    self.movePlayerFlags = 2
                    self.moveDown()
            elif rect2.y() < 185 and rect2.y() >= 95:
                if rect2.x() == 320 or rect2.x() == 456:
                    self.movePlayerFlags = 2
                    self.moveDown()

    def closeEvent(self, event):
        self.key_notifyer.die()
        self.monkey_movement.die()
        self.barrel_movement.die()
        self.points_counter.die()
        self.unexpected_force.die()
        self.delayed_effect_of_force.die()
        self.unexpected_force_life.quit()
        self.unexpected_force_bomb.quit()
        self.process.terminate()
        self.process2.terminate()

    def moveLeft(self):
        player = self.avatarLable.geometry()
        player2 = self.avatarLable2.geometry()

        if self.movePlayerFlags == 1:
            if self.moveLeftFlags == 0:
                avatarImage = QPixmap("Assets/Mario/marioL1.png")
            elif self.moveLeftFlags == 1:
                avatarImage = QPixmap("Assets/Mario/marioL2.png")

            avatarImageCropped = avatarImage.scaled(30, 40,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.FastTransformation)
            self.avatarLable.setPixmap(QPixmap(avatarImageCropped))
            self.avatarLable.move(player.x() - 8, player.y())

            if self.moveLeftFlags == 0:
                self.moveLeftFlags = 1
            else:
                self.moveLeftFlags = 0

        elif self.movePlayerFlags == 2:

            if self.moveLeft2Flags == 0:
                avatarImage = QPixmap("Assets/Mario/mario2L1.png")
            elif self.moveLeft2Flags == 1:
                avatarImage = QPixmap("Assets/Mario/mario2L2.png")

            avatarImageCropped = avatarImage.scaled(30, 40,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.FastTransformation)
            self.avatarLable2.setPixmap(QPixmap(avatarImageCropped))
            self.avatarLable2.move(player2.x() - 8, player2.y())

            if self.moveLeft2Flags == 0:
                self.moveLeft2Flags = 1
            else:
                self.moveLeft2Flags = 0

        self.movePlayerFlags = 0

    def moveRight(self):
        player = self.avatarLable.geometry()
        player2 = self.avatarLable2.geometry()

        if self.movePlayerFlags == 1:
            if self.moveRightFlags == 0:
                avatarImage = QPixmap("Assets/Mario/marioR1.png")
            elif self.moveRightFlags == 1:
                avatarImage = QPixmap("Assets/Mario/marioR2.png")

            avatarImageCropped = avatarImage.scaled(30, 40,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.FastTransformation)
            self.avatarLable.setPixmap(QPixmap(avatarImageCropped))
            self.avatarLable.move(player.x() + 8, player.y())

            if self.moveRightFlags == 0:
                self.moveRightFlags = 1
            else:
                self.moveRightFlags = 0

        elif self.movePlayerFlags == 2:

            if self.moveRight2Flags == 0:
                avatarImage = QPixmap("Assets/Mario/mario2R1.png")
            elif self.moveRight2Flags == 1:
                avatarImage = QPixmap("Assets/Mario/mario2R2.png")

            avatarImageCropped = avatarImage.scaled(30, 40,
                                                    Qt.IgnoreAspectRatio,
                                                    Qt.FastTransformation)
            self.avatarLable2.setPixmap(QPixmap(avatarImageCropped))
            self.avatarLable2.move(player2.x() + 8, player2.y())

            if self.moveRight2Flags == 0:
                self.moveRight2Flags = 1
            else:
                self.moveRight2Flags = 0

        self.movePlayerFlags = 0

    def moveUp(self):
        if self.movePlayerFlags == 1:
            self.cekanjePlayer1_1 = self.cekanjePlayer1_1 + 1

            if self.cekanjePlayer1_1 % 2 == 0:
                if self.moveUpFlags == 0:
                    avatarImage = QPixmap("Assets/Mario/marioUp1.png")
                elif self.moveUpFlags == 1:
                    avatarImage = QPixmap("Assets/Mario/marioUp11.png")

                if self.moveUpFlags == 0:
                    self.moveUpFlags = 1
                else:
                    self.moveUpFlags = 0

                avatarImageCropped = avatarImage.scaled(
                    30, 40, Qt.IgnoreAspectRatio, Qt.FastTransformation)
                self.avatarLable.setPixmap(QPixmap(avatarImageCropped))

            nivo = self.avatarLable.geometry().y()
            x = self.avatarLable.geometry().x()

            if self.OnLadderOrBrokenLadder(nivo, x, 'Up'):
                self.avatarLable.move(x, nivo - 3)

        elif self.movePlayerFlags == 2:
            self.cekanjePlayer2_1 = self.cekanjePlayer2_1 + 1

            if self.cekanjePlayer2_1 % 2 == 0:
                if self.moveUp2Flags == 0:
                    avatarImage = QPixmap("Assets/Mario/mario2Up1.png")
                elif self.moveUp2Flags == 1:
                    avatarImage = QPixmap("Assets/Mario/mario2Up2.png")

                if self.moveUp2Flags == 0:
                    self.moveUp2Flags = 1
                else:
                    self.moveUp2Flags = 0

                avatarImageCropped = avatarImage.scaled(
                    30, 40, Qt.IgnoreAspectRatio, Qt.FastTransformation)
                self.avatarLable2.setPixmap(QPixmap(avatarImageCropped))

            nivo = self.avatarLable2.geometry().y()
            x = self.avatarLable2.geometry().x()

            if self.OnLadderOrBrokenLadder(nivo, x, 'Up'):
                self.avatarLable2.move(x, nivo - 3)

        self.movePlayerFlags = 0

    def moveDown(self):

        if self.movePlayerFlags == 1:
            self.cekanjePlayer1_2 = self.cekanjePlayer1_2 + 1

            if self.cekanjePlayer1_2 % 2 == 0:
                if self.moveDownFlags == 0:
                    avatarImage = QPixmap("Assets/Mario/marioUp1.png")
                elif self.moveDownFlags == 1:
                    avatarImage = QPixmap("Assets/Mario/marioUp11.png")

                if self.moveDownFlags == 0:
                    self.moveDownFlags = 1
                else:
                    self.moveDownFlags = 0

                avatarImageCropped = avatarImage.scaled(
                    30, 40, Qt.IgnoreAspectRatio, Qt.FastTransformation)
                self.avatarLable.setPixmap(QPixmap(avatarImageCropped))

            nivo = self.avatarLable.geometry().y()
            x = self.avatarLable.geometry().x()

            if self.OnLadderOrBrokenLadder(nivo, x, 'Down'):
                self.avatarLable.move(x, nivo + 3)

        elif self.movePlayerFlags == 2:
            self.cekanjePlayer2_2 = self.cekanjePlayer2_2 + 1

            if self.cekanjePlayer2_2 % 2 == 0:
                if self.moveDown2Flags == 0:
                    avatarImage = QPixmap("Assets/Mario/mario2Up1.png")
                elif self.moveDown2Flags == 1:
                    avatarImage = QPixmap("Assets/Mario/mario2Up2.png")

                if self.moveDown2Flags == 0:
                    self.moveDown2Flags = 1
                else:
                    self.moveDown2Flags = 0

                avatarImageCropped = avatarImage.scaled(
                    30, 40, Qt.IgnoreAspectRatio, Qt.FastTransformation)
                self.avatarLable2.setPixmap(QPixmap(avatarImageCropped))

            nivo = self.avatarLable2.geometry().y()
            x = self.avatarLable2.geometry().x()

            if self.OnLadderOrBrokenLadder(nivo, x, 'Down'):
                self.avatarLable2.move(x, nivo + 3)

        self.movePlayerFlags = 0

    def OnLadderOrBrokenLadder(self, nivo, x, direction):
        dodatak = 0
        if direction == 'Up':
            dodatak = 2

        if nivo <= 543 + dodatak and nivo >= 455 + dodatak:
            if x == 352 or x == 424:
                return True
        elif nivo <= 453 + dodatak and nivo >= 365 + dodatak:
            if x == 48 or x == 728:
                return True
        elif nivo <= 363 + dodatak and nivo >= 275 + dodatak:
            if x == 352 or x == 424:
                return True
        elif nivo <= 273 + dodatak and nivo >= 185 + dodatak:
            if x == 48 or x == 728:
                return True
        elif nivo <= 183 + dodatak and nivo >= 95 + dodatak:
            if x == 320 or x == 456:
                return True
        ''' Move down on broken Ladder '''

        if nivo <= 543 + dodatak and nivo >= 521 + dodatak:
            if x == 72 or x == 696:
                return True
        elif nivo <= 453 + dodatak and nivo >= 431 + dodatak:
            if x == 320 or x == 456:
                return True
        elif nivo <= 363 + dodatak and nivo >= 341 + dodatak:
            if x == 72 or x == 696:
                return True
        elif nivo <= 273 + dodatak and nivo >= 251 + dodatak:
            if x == 320 or x == 456:
                return True

        return False

    def refreshPoints(self):
        position1 = self.avatarLable.geometry().y()
        position2 = self.avatarLable2.geometry().y()

        if position1 == 545:
            self.first[0] = True
        elif position1 == 455:
            self.first[0] = False
            self.first[1] = True
        elif position1 == 365:
            self.first[1] = False
            self.first[2] = True
        elif position1 == 275:
            self.first[2] = False
            self.first[3] = True
        elif position1 == 185:
            self.first[3] = False
            self.first[4] = True
        elif position1 == 95:
            self.first[4] = False
            self.first[5] = True
        else:
            self.first[5] = False

        if self.first[0] == True:
            self.point1 = 0 + self.pamtiPrvog
            self.first[0] = False
        elif self.first[1] == True:
            self.point1 = 1 + self.pamtiPrvog
            self.first[1] = False
        elif self.first[2] == True:
            self.point1 = 2 + self.pamtiPrvog
            self.first[2] = False
        elif self.first[3] == True:
            self.point1 = 3 + self.pamtiPrvog
            self.first[3] = False
        elif self.first[4] == True:
            self.point1 = 4 + self.pamtiPrvog
            self.first[4] = False
        elif self.first[5] == True:
            self.point1 = 5 + self.pamtiPrvog
            self.first[5] = False
            self.pamtiPrvog = self.point1
            self.pamtiDrugog = self.point2
            self.newLevel()
        else:
            self.point1 = self.point1

        if position2 == 545:
            self.second[0] = True
        elif position2 == 455:
            self.second[0] = False
            self.second[1] = True
        elif position2 == 365:
            self.second[1] = False
            self.second[2] = True
        elif position2 == 275:
            self.second[2] = False
            self.second[3] = True
        elif position2 == 185:
            self.second[3] = False
            self.second[4] = True
        elif position2 == 95:
            self.second[4] = False
            self.second[5] = True
        else:
            self.second[5] = False

        if self.second[0] == True:
            self.point2 = 0 + self.pamtiDrugog
            self.second[0] = False
        elif self.second[1] == True:
            self.point2 = 1 + self.pamtiDrugog
            self.second[1] = False
        elif self.second[2] == True:
            self.point2 = 2 + self.pamtiDrugog
            self.second[2] = False
        elif self.second[3] == True:
            self.point2 = 3 + self.pamtiDrugog
            self.second[3] = False
        elif self.second[4] == True:
            self.point2 = 4 + self.pamtiDrugog
            self.second[4] = False
        elif self.second[5] == True:
            self.point2 = 5 + self.pamtiDrugog
            self.second[5] = False
            self.pamtiDrugog = self.point2
            self.pamtiPrvog = self.point1
            self.newLevel()
        else:
            self.point2 = self.point2

        self.player1score.setText('Score: ' + str(self.point1))
        self.player2score.setText('Score: ' + str(self.point2))

    def showLifeForce(self):
        self.forceLife = QLabel(self)
        forceLifeImage = QPixmap('Assets/Heart/Life.png')
        self.forceLife.setStyleSheet(
            'QLabel { background-color: transparent }')
        forceLifeImageCropped = forceLifeImage.scaled(20, 20,
                                                      Qt.IgnoreAspectRatio,
                                                      Qt.FastTransformation)
        self.forceLife.setPixmap(QPixmap(forceLifeImageCropped))

        randX = self.queueLifeX.get()
        randY = self.queueLifeY.get()

        self.forceLife.move(randX, randY)
        self.forceLife.show()

        self.LifeExist = True

    def hideLifeForce(self):
        self.forceLife.clear()
        self.LifeExist = False

    def showBombForce(self):
        self.forceBomb = QLabel(self)
        forceBombImage = QPixmap('Assets/Heart/FlameBomb.png')
        self.forceBomb.setStyleSheet(
            'QLabel { background-color: transparent }')
        forceBombImageCropped = forceBombImage.scaled(20, 20,
                                                      Qt.IgnoreAspectRatio,
                                                      Qt.FastTransformation)
        self.forceBomb.setPixmap(QPixmap(forceBombImageCropped))

        randX = self.queueBombX.get()
        randY = self.queueBombY.get()

        self.forceBomb.move(randX, randY)

        self.forceBomb.show()

        self.bombExist = True

    def hideBombForce(self):
        self.forceBomb.clear()
        self.bombExist = False

    def center(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())

    def newLevel(self):
        self.level = self.level + 1
        self.levelLabel.setText('Level ' + str(self.level))

        self.monkeyLabel.move(375, 155)
        self.avatarLable.move(40, 545)
        self.avatarLable2.move(720, 545)

        self.monkey_movement.die()
        self.barrel_movement.die()

        for b in self.barrels:
            b.hide()
            #self.barrels.remove(b)

        self.barrels.clear()
        '''
        image1 = QPixmap('Assets/Brick/Platforma.png')
        image2 = QPixmap('Assets/Brick/BluePlatform.png')
        image3 = QPixmap('Assets/Brick/RedPlatform.png')

        sirina = 800 / 54

        for p in self.PlatformList:
            p.hide()

        self.PlatformList.clear()

        if self.level % 3 == 1:
            croppedImage = image1.scaled(20, 20, Qt.IgnoreAspectRatio, Qt.FastTransformation)

            for i in range(1, 6):
                for j in range(38):
                    self.PlatformList.append(self.setPlatform(croppedImage, i, j, sirina))

                self.PlatformList.append(self.setPlatform(croppedImage, i, 38, sirina))

        elif self.level % 3 == 2:
            croppedImage = image2.scaled(20, 20, Qt.IgnoreAspectRatio, Qt.FastTransformation)

            for i in range(1, 6):
                for j in range(38):
                    self.PlatformList.append(self.setPlatform(croppedImage, i, j, sirina))

                self.PlatformList.append(self.setPlatform(croppedImage, i, 38, sirina))

        else:
            croppedImage = image3.scaled(20, 20, Qt.IgnoreAspectRatio, Qt.FastTransformation)

            for i in range(1, 6):
                for j in range(38):
                    self.PlatformList.append(self.setPlatform(croppedImage, i, j, sirina))

                self.PlatformList.append(self.setPlatform(croppedImage, i, 38, sirina))'''

        self.avatarLable.show()
        self.avatarLable2.show()

        #self.monkey_movement.move_monkey_signal.connect(self.moveMonkey)
        self.monkey_movement.start(self.level)

        #self.barrel_movement.move_barrel_signal.connect(self.moveBarrel)
        self.barrel_movement.start(self.level)

    def isGameOver(self):
        if self.Lives1 > 0 and self.Lives2 == 0:
            self.pobednik = 1
        elif self.Lives1 == 0 and self.Lives2 > 0:
            self.pobednik = 2
        elif self.Lives1 == 0 and self.Lives2 == 0:
            #gameOver(self.pobdnik)
            #print("Pobednik: " + str(self.pobednik))
            winnerName = ""
            score = 0
            if self.pobednik == 1:
                winnerName = self.nameOne
                score = self.point1
            elif self.pobednik == 2:
                winnerName = self.nameTwo
                score = self.point2

            self.gameOver = GameOver(winnerName, score)
            self.close()

    def checkCollisionWithUnexpectedForce(self):
        if self.LifeExist:
            if self.isHit(self.forceLife, self.avatarLable):
                self.unexpected_force.forces[0] = True
                self.forceLife.clear()
                #self.delayed_effect_of_force.start()
                self.LifeExist = False

        if self.bombExist:
            if self.isHit(self.forceBomb, self.avatarLable):
                self.unexpected_force.forces[1] = True
                self.forceBomb.clear()
                self.bombExist = False

        if self.LifeExist:
            if self.isHit(self.forceLife, self.avatarLable2):
                self.unexpected_force.forces[2] = True
                self.forceLife.clear()
                self.LifeExist = False

        if self.bombExist:
            if self.isHit(self.forceBomb, self.avatarLable2):
                self.unexpected_force.forces[3] = True
                self.forceBomb.clear()
                self.bombExist = False

    def executeForce(self, force):
        if force == 1:
            self.Lives1 = self.Lives1 + 1
            self.player1lives.setText('Lives: ' + str(self.Lives1))
            print(str(self.Lives1))
        elif force == 2:
            self.Lives1 = self.Lives1 - 1
            self.player1lives.setText('Lives: ' + str(self.Lives1))
            print(str(self.Lives1))

            if self.Lives1 > 0:
                self.avatarLable.move(40, 545)
            else:
                self.isLive1 = False
                self.avatarLable.clear()
                self.avatarLable.move(1100, 1100)

            self.isGameOver()

    def executeForce2(self, force):
        if force == 1:
            self.Lives2 = self.Lives2 + 1
            self.player2lives.setText('Lives: ' + str(self.Lives2))
        elif force == 2:
            self.Lives2 = self.Lives2 - 1
            self.player2lives.setText('Lives: ' + str(self.Lives2))

            if self.Lives2 > 0:
                self.avatarLable2.move(720, 545)
            else:
                self.isLive2 = False
                self.avatarLable2.clear()
                self.avatarLable2.move(1100, 1100)

            self.isGameOver()
Beispiel #11
0
class ImagePlayer(QWidget):
    def __init__(self, filename, title, parent=None):
        super(ImagePlayer, self).__init__()

        #set screen save
        self.settings = QSettings('settings.ini', QSettings.IniFormat)

        # set up exit action
        quitAction = QAction("E&xit",
                             self,
                             shortcut="Ctrl+Q",
                             triggered=self.close)
        self.addAction(quitAction)
        self.setContextMenuPolicy(Qt.ActionsContextMenu)

        # Load the file into a QMovie
        self.movie = QMovie(filename, QByteArray(), self)

        #size = self.movie.scaledSize()
        self.setWindowFlags(Qt.FramelessWindowHint
                            | Qt.WindowStaysOnBottomHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        #self.resize(self.settings.value("size", QSize(size.width, size.height)))
        self.move(self.settings.value("pos", QPoint(50, 50)))
        #self.setGeometry(parser.getint('screen_position', 'x'), parser.getint('screen_position', 'y'), size.width(), size.height())
        self.setWindowTitle(title)

        self.movie_screen = QLabel()
        # Make label fit the gif
        self.movie_screen.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
        self.movie_screen.setAlignment(Qt.AlignCenter)
        self.movie_screen.setScaledContents(
            True)  #allow image to scale with label
        self.setMinimumSize(QSize(200, 150))  #restrict it to a min size
        self.movie_screen.setStyleSheet(open('style.css').read())

        # Create the layout
        main_layout = QVBoxLayout()
        sizegrip = QSizeGrip(
            self)  #enable size grip for scaling borderless window
        main_layout.addWidget(self.movie_screen)
        main_layout.addWidget(sizegrip, 0, Qt.AlignBottom | Qt.AlignRight)

        self.setLayout(main_layout)

        # Add the QMovie object to the label
        self.movie.setCacheMode(QMovie.CacheAll)
        self.movie.setSpeed(self.settings.value(
            "playspeed", 30,
            type=int))  #set relative playback speed percentage
        self.movie_screen.setMovie(self.movie)
        self.movie.start()
        self.movie.loopCount()

        self.timer = QTimer(self)
        self.timer.singleShot(2000, self.GetMap)
        self.timer.timeout.connect(self.GetMap)
        self.timer.start(901000)  #milliseconds. 1000 is 1 second

    #override closing the program. use self.close to call this
    def closeEvent(self, event):
        #self.settings.setValue("size", self.size())
        self.settings.setValue("pos", self.pos())
        event.accept()

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.dragposition = event.globalPos() - self.frameGeometry(
            ).topLeft()
            event.accept()

    def mouseMoveEvent(self, event):
        if event.buttons() == Qt.LeftButton:
            self.move(event.globalPos() - self.dragposition)
            event.accept()

    def GetMap(self):
        r.downloadCheck('NatLoop.gif')
        #gifcropper.gifcrop(1361, 500, 510, 270) #TODO: only crop if gif updates
        gifcropper.gifcrop(
            self.settings.value("x", 1361, type=int),
            self.settings.value("y", 500, type=int),
            self.settings.value("width", 510, type=int),
            self.settings.value("height", 270,
                                type=int))  #TODO: only crop if gif updates
        self.movie = QMovie(gif, QByteArray(), self)
        self.movie_screen.setMovie(self.movie)
        self.movie.setSpeed(self.settings.value(
            "playspeed", 30,
            type=int))  #set relative playback speed percentage
        self.movie.start()
        print("refresh done")

    def simpleGetMap(self):
        r.SimpleDownload('NatLoop.gif')
        gifcropper.gifcrop(
            self.settings.value("x", 1361, type=int),
            self.settings.value("y", 500, type=int),
            self.settings.value("width", 510, type=int),
            self.settings.value("height", 270,
                                type=int))  #TODO: only crop if gif updates
        self.movie = QMovie(gif, QByteArray(), self)
        self.movie_screen.setMovie(self.movie)
        self.movie.setSpeed(self.settings.value("playspeed", 30, type=int))
        self.movie.start()
        print("refresh done")
        self.movie_screen.setMovie(self.movie)
        self.movie.start

    def speedsetter(self, speed):
        self.movie.setSpeed(speed)
        self.settings.setValue("playspeed", speed)

    def mapsetter(self, x, y, w, h):
        self.settings.setValue("x", x)
        self.settings.setValue("y", y)
        self.settings.setValue("width", w)
        self.settings.setValue("height", h)
        self.simpleGetMap()