add long right click detection
This commit is contained in:
parent
5a73731542
commit
3a1c63f4ce
13
vpet.py
13
vpet.py
@ -65,6 +65,7 @@ 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
|
||||||
@ -74,6 +75,7 @@ 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
|
||||||
@ -81,6 +83,7 @@ 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
|
||||||
@ -88,12 +91,14 @@ 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
|
||||||
@ -106,6 +111,7 @@ 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
|
||||||
@ -124,6 +130,7 @@ class VPet:
|
|||||||
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.p = 0
|
||||||
|
|
||||||
self.move = move
|
self.move = move
|
||||||
self.draw = draw
|
self.draw = draw
|
||||||
@ -131,9 +138,13 @@ class VPet:
|
|||||||
self.activity = Activity()
|
self.activity = Activity()
|
||||||
|
|
||||||
def action_loop(self):
|
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
|
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:
|
if self.activity.is_sleeping:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -40,16 +40,19 @@ 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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user