diff --git a/main.py b/main.py index e69de29..ba3f2bb 100644 --- a/main.py +++ b/main.py @@ -0,0 +1,7 @@ +from PyQt5.QtWidgets import QApplication +from window_qt import MainWindow + + +app = QApplication([]) +window = MainWindow() +app.exec_() diff --git a/requierements.txt b/requierements.txt index 8b39345..cd59c09 100644 --- a/requierements.txt +++ b/requierements.txt @@ -1,4 +1,5 @@ +screeninfo PyOpenGL -PyGObject-stubs PyQt5 -PyQt5-stubs \ No newline at end of file +PyGObject-stubs +PyQt5-stubs diff --git a/vpet.py b/vpet.py index 2c03f07..398748d 100644 --- a/vpet.py +++ b/vpet.py @@ -122,15 +122,15 @@ class Activity: class VPet: - def __init__(self, move, pos, draw, x=0, y=100, screen=1): - self.screen = screen + def __init__(self, move, pos, draw, monitor, x=0, y=0,): + self.monitor = monitor self.pos = pos self.x_postion = x self.y_postion = y self.x_destination = 0 self.y_destination = 0 self.rotation = Rotate.up - self.p = 0 + self.is_busy = False self.move = move self.draw = draw @@ -138,17 +138,24 @@ class VPet: self.activity = Activity() def action_loop(self): - # print(f'Interacting with user: {self.activity.is_interacting_with_user}') - self.update_position() - print(self.x_postion, self.y_postion) - if self.activity.is_interacting_with_user: return - self.x_postion = self.pos().x() + 3 + if self.activity.is_interacting_with_user: + self.is_busy = True + return + + if not self.activity.is_interacting_with_user and self.is_busy: + self.update_position() + self.is_busy = False + self.activity.set_idle() + + self.x_postion += 3 self.draw(self.frames.idle_1) self.move(self.x_postion, self.y_postion) - + self.update_position() + def update_position(self): self.x_postion = self.pos().x() self.y_postion = self.pos().y() + print(self.x_postion, self.y_postion) def choose_walk_destination(self): """Decide, where the VPet should move to""" diff --git a/window_qt.py b/window_qt.py index ad4a6f6..2317252 100755 --- a/window_qt.py +++ b/window_qt.py @@ -1,26 +1,33 @@ -#!/bin/python3 - import time +from time import sleep + from PyQt5.QtWidgets import QMainWindow -from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import Qt, QTimer +from screeninfo import get_monitors from transparent_widget import TransparentGLWidget from vpet import Rotate from vpet import VPet +def get_primary_monitor(): + m = next((monitor for monitor in get_monitors() if monitor.is_primary), None) + print(m.height) + print(m.width) + print(int(m.width/2)) + return m + + class MainWindow(QMainWindow): def __init__(self): super().__init__() self.FPS = 60 - self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) - # self.setWindowFlags(Qt.WindowStaysOnTopHint) - self.setAttribute(Qt.WA_TranslucentBackground) + self.primary_monitor = get_primary_monitor() + # self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) + self.setWindowFlags(Qt.WindowStaysOnTopHint) + # self.setAttribute(Qt.WA_TranslucentBackground) self.click_event_time = 0 - - self.v_pet = VPet(self.move, self.pos, self.draw) - + self.v_pet = VPet(self.move, self.pos, self.draw, self.primary_monitor, x=int(self.primary_monitor.width/2), y=self.primary_monitor.height) self.loop_timer = QTimer(self) self.loop_timer.setSingleShot(False) self.loop_timer.setInterval(self.FPS) @@ -62,8 +69,3 @@ class MainWindow(QMainWindow): def loop(self): self.v_pet.action_loop() self.show() - - -app = QApplication([]) -window = MainWindow() -app.exec_()