add long right click detection

This commit is contained in:
DasMoorhuhn 2024-12-12 04:33:57 +01:00
parent 5a73731542
commit 3a1c63f4ce
2 changed files with 16 additions and 2 deletions

13
vpet.py
View File

@ -65,6 +65,7 @@ class Activity:
self.is_interacting_with_user = False
def set_idle(self):
print('Setting idle')
self.is_idle = True
self.is_sleeping = False
self.is_dreaming = False
@ -74,6 +75,7 @@ class Activity:
self.is_interacting_with_user = False
def set_sleeping(self):
print('Setting sleeping')
self.is_idle = False
self.is_sleeping = True
self.is_moving = False
@ -81,6 +83,7 @@ class Activity:
self.is_thinking = False
def set_dreaming(self):
print('Setting dreaming')
self.is_idle = False
self.is_dreaming = True
self.is_moving = False
@ -88,12 +91,14 @@ class Activity:
self.is_thinking = False
def set_moving(self):
print('Setting moving')
self.is_idle = False
self.is_moving = True
self.is_sleeping = False
self.is_dreaming = False
def set_talking(self):
print('Setting talking')
self.is_idle = False
self.is_talking = True
self.is_thinking = False
@ -106,6 +111,7 @@ class Activity:
self.is_sleeping = False
def set_interacting_with_user(self):
print('Setting interacting with user')
self.is_idle = False
self.is_sleeping = False
self.is_dreaming = False
@ -124,6 +130,7 @@ class VPet:
self.x_destination = 0
self.y_destination = 0
self.rotation = Rotate.up
self.p = 0
self.move = move
self.draw = draw
@ -131,9 +138,13 @@ class VPet:
self.activity = Activity()
def action_loop(self):
print(f'Interacting with user: {self.activity.is_interacting_with_user}')
# print(f'Interacting with user: {self.activity.is_interacting_with_user}')
if self.activity.is_interacting_with_user: return
self.move(self.x_postion, self.y_postion)
self.x_postion = self.pos().x() + 1
self.y_postion = self.pos().y()
if self.activity.is_sleeping:
pass

View File

@ -40,16 +40,19 @@ class MainWindow(QMainWindow):
print('Click left')
if event.button() == Qt.RightButton:
print('Click right')
else:
if event.button() == Qt.RightButton:
print('Click long right')
self.click_event_time = 0
self.v_pet.activity.is_interacting_with_user = False
def mouseMoveEvent(self, event):
self.click_event_time = 0
if event.buttons() == Qt.LeftButton:
delta = event.globalPos() - self.drag_position
self.move(self.pos() + delta)
self.drag_position = event.globalPos()
self.click_event_time = 0
def draw(self, img):
img = img.rotate(Rotate.up)