Compare commits
No commits in common. "develop" and "main" have entirely different histories.
7
main.py
7
main.py
@ -1,7 +0,0 @@
|
|||||||
from PyQt5.QtWidgets import QApplication
|
|
||||||
from window_qt import MainWindow
|
|
||||||
|
|
||||||
|
|
||||||
app = QApplication([])
|
|
||||||
window = MainWindow()
|
|
||||||
app.exec_()
|
|
||||||
@ -1,5 +1,4 @@
|
|||||||
screeninfo
|
|
||||||
PyOpenGL
|
PyOpenGL
|
||||||
PyQt5
|
|
||||||
PyGObject-stubs
|
PyGObject-stubs
|
||||||
|
PyQt5
|
||||||
PyQt5-stubs
|
PyQt5-stubs
|
||||||
35
vpet.py
35
vpet.py
@ -65,7 +65,6 @@ class Activity:
|
|||||||
self.is_interacting_with_user = False
|
self.is_interacting_with_user = False
|
||||||
|
|
||||||
def set_idle(self):
|
def set_idle(self):
|
||||||
print('Setting idle')
|
|
||||||
self.is_idle = True
|
self.is_idle = True
|
||||||
self.is_sleeping = False
|
self.is_sleeping = False
|
||||||
self.is_dreaming = False
|
self.is_dreaming = False
|
||||||
@ -75,7 +74,6 @@ class Activity:
|
|||||||
self.is_interacting_with_user = False
|
self.is_interacting_with_user = False
|
||||||
|
|
||||||
def set_sleeping(self):
|
def set_sleeping(self):
|
||||||
print('Setting sleeping')
|
|
||||||
self.is_idle = False
|
self.is_idle = False
|
||||||
self.is_sleeping = True
|
self.is_sleeping = True
|
||||||
self.is_moving = False
|
self.is_moving = False
|
||||||
@ -83,7 +81,6 @@ class Activity:
|
|||||||
self.is_thinking = False
|
self.is_thinking = False
|
||||||
|
|
||||||
def set_dreaming(self):
|
def set_dreaming(self):
|
||||||
print('Setting dreaming')
|
|
||||||
self.is_idle = False
|
self.is_idle = False
|
||||||
self.is_dreaming = True
|
self.is_dreaming = True
|
||||||
self.is_moving = False
|
self.is_moving = False
|
||||||
@ -91,14 +88,12 @@ class Activity:
|
|||||||
self.is_thinking = False
|
self.is_thinking = False
|
||||||
|
|
||||||
def set_moving(self):
|
def set_moving(self):
|
||||||
print('Setting moving')
|
|
||||||
self.is_idle = False
|
self.is_idle = False
|
||||||
self.is_moving = True
|
self.is_moving = True
|
||||||
self.is_sleeping = False
|
self.is_sleeping = False
|
||||||
self.is_dreaming = False
|
self.is_dreaming = False
|
||||||
|
|
||||||
def set_talking(self):
|
def set_talking(self):
|
||||||
print('Setting talking')
|
|
||||||
self.is_idle = False
|
self.is_idle = False
|
||||||
self.is_talking = True
|
self.is_talking = True
|
||||||
self.is_thinking = False
|
self.is_thinking = False
|
||||||
@ -111,7 +106,6 @@ class Activity:
|
|||||||
self.is_sleeping = False
|
self.is_sleeping = False
|
||||||
|
|
||||||
def set_interacting_with_user(self):
|
def set_interacting_with_user(self):
|
||||||
print('Setting interacting with user')
|
|
||||||
self.is_idle = False
|
self.is_idle = False
|
||||||
self.is_sleeping = False
|
self.is_sleeping = False
|
||||||
self.is_dreaming = False
|
self.is_dreaming = False
|
||||||
@ -122,43 +116,26 @@ class Activity:
|
|||||||
|
|
||||||
|
|
||||||
class VPet:
|
class VPet:
|
||||||
def __init__(self, move, pos, draw, monitor, x=0, y=0,):
|
def __init__(self, move, pos, draw, x=0, y=0, screen=1):
|
||||||
self.monitor = monitor
|
self.screen = screen
|
||||||
self.pos = pos
|
self.pos = pos
|
||||||
self.x_postion = x
|
self.x_postion = x
|
||||||
self.y_postion = y
|
self.y_postion = y
|
||||||
self.x_destination = 0
|
self.x_destination = 0
|
||||||
self.y_destination = 0
|
self.y_destination = 0
|
||||||
self.rotation = Rotate.up
|
self.rotation = Rotate.up
|
||||||
self.is_busy = False
|
|
||||||
|
|
||||||
self.move = move
|
self.move = move
|
||||||
self.draw = draw
|
self.draw = draw
|
||||||
self.frames = Frames()
|
self.frames = Frames()
|
||||||
self.activity = Activity()
|
self.activity = Activity()
|
||||||
|
|
||||||
self.animation_start = 0
|
|
||||||
self.animation_end = 0
|
|
||||||
|
|
||||||
def action_loop(self):
|
def action_loop(self):
|
||||||
if self.activity.is_interacting_with_user:
|
print(f'Interacting with user: {self.activity.is_interacting_with_user}')
|
||||||
self.is_busy = True
|
if self.activity.is_interacting_with_user: return
|
||||||
return
|
|
||||||
|
|
||||||
if not self.activity.is_interacting_with_user and self.is_busy:
|
if self.activity.is_sleeping:
|
||||||
self.update_position()
|
pass
|
||||||
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):
|
def choose_walk_destination(self):
|
||||||
"""Decide, where the VPet should move to"""
|
"""Decide, where the VPet should move to"""
|
||||||
|
|||||||
35
window_qt.py
35
window_qt.py
@ -1,38 +1,29 @@
|
|||||||
import time
|
#!/bin/python3
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
|
import time
|
||||||
from PyQt5.QtWidgets import QMainWindow
|
from PyQt5.QtWidgets import QMainWindow
|
||||||
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtCore import Qt, QTimer
|
from PyQt5.QtCore import Qt, QTimer
|
||||||
from screeninfo import get_monitors
|
|
||||||
|
|
||||||
from transparent_widget import TransparentGLWidget
|
from transparent_widget import TransparentGLWidget
|
||||||
from vpet import Rotate
|
from vpet import Rotate
|
||||||
from vpet import VPet
|
from vpet import VPet
|
||||||
|
|
||||||
|
|
||||||
def get_primary_monitor():
|
|
||||||
return next((monitor for monitor in get_monitors() if monitor.is_primary), None)
|
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.interval = 60
|
self.FPS = 60
|
||||||
self.primary_monitor = get_primary_monitor()
|
|
||||||
# self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
# self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
||||||
self.setWindowFlags(Qt.WindowStaysOnTopHint)
|
self.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||||
# self.setAttribute(Qt.WA_TranslucentBackground)
|
self.setAttribute(Qt.WA_TranslucentBackground)
|
||||||
self.click_event_time = 0
|
self.click_event_time = 0
|
||||||
self.v_pet = VPet(self.move,
|
|
||||||
self.pos,
|
self.v_pet = VPet(self.move, self.pos, self.draw)
|
||||||
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 = QTimer(self)
|
||||||
self.loop_timer.setSingleShot(False)
|
self.loop_timer.setSingleShot(False)
|
||||||
self.loop_timer.setInterval(self.interval)
|
self.loop_timer.setInterval(self.FPS)
|
||||||
self.loop_timer.timeout.connect(self.loop)
|
self.loop_timer.timeout.connect(self.loop)
|
||||||
self.loop_timer.start()
|
self.loop_timer.start()
|
||||||
|
|
||||||
@ -49,19 +40,16 @@ class MainWindow(QMainWindow):
|
|||||||
print('Click left')
|
print('Click left')
|
||||||
if event.button() == Qt.RightButton:
|
if event.button() == Qt.RightButton:
|
||||||
print('Click right')
|
print('Click right')
|
||||||
else:
|
|
||||||
if event.button() == Qt.RightButton:
|
|
||||||
print('Click long right')
|
|
||||||
|
|
||||||
self.click_event_time = 0
|
self.click_event_time = 0
|
||||||
self.v_pet.activity.is_interacting_with_user = False
|
self.v_pet.activity.is_interacting_with_user = False
|
||||||
|
|
||||||
def mouseMoveEvent(self, event):
|
def mouseMoveEvent(self, event):
|
||||||
|
self.click_event_time = 0
|
||||||
if event.buttons() == Qt.LeftButton:
|
if event.buttons() == Qt.LeftButton:
|
||||||
delta = event.globalPos() - self.drag_position
|
delta = event.globalPos() - self.drag_position
|
||||||
self.move(self.pos() + delta)
|
self.move(self.pos() + delta)
|
||||||
self.drag_position = event.globalPos()
|
self.drag_position = event.globalPos()
|
||||||
self.click_event_time = 0
|
|
||||||
|
|
||||||
def draw(self, img):
|
def draw(self, img):
|
||||||
img = img.rotate(Rotate.up)
|
img = img.rotate(Rotate.up)
|
||||||
@ -71,3 +59,8 @@ class MainWindow(QMainWindow):
|
|||||||
def loop(self):
|
def loop(self):
|
||||||
self.v_pet.action_loop()
|
self.v_pet.action_loop()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
|
||||||
|
app = QApplication([])
|
||||||
|
window = MainWindow()
|
||||||
|
app.exec_()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user