Hi all,
Is it possible to create a circular QTE-like motion for a button press in Renpy? There's a moment in my game where you have to use a key to unlock a door, and I thought it'd be more immersive to turn the key in a circle to do so (instead of pressing a button).
I think I'll want to use drag for this, but I don't know how to set it up to work on rotation. I'd like the door to unlock when the key has been rotated 360 degrees clockwise but have no idea how to do this. Has this been done before?
Thanks
Circular QTE-like button press
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Re: Circular QTE-like button press
In theory, you could do this with a custom Displayable, because in there you have access to the low level mouse events. You’d have to write the code to track the position of the mouse and decide what it had followed the path you wanted. Probably not trivial...
https://www.renpy.org/doc/html/udd.html
https://www.renpy.org/doc/html/udd.html
- Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
- Contact:
Re: Circular QTE-like button press
Kinmoku wrote: ↑Thu Oct 31, 2019 7:09 am Hi all,
Is it possible to create a circular QTE-like motion for a button press in Renpy? There's a moment in my game where you have to use a key to unlock a door, and I thought it'd be more immersive to turn the key in a circle to do so (instead of pressing a button).
I think I'll want to use drag for this, but I don't know how to set it up to work on rotation. I'd like the door to unlock when the key has been rotated 360 degrees clockwise but have no idea how to do this. Has this been done before?
Thanks
I think you could do it like this.
You have an image of your lock. You have images of the key at different degrees of turning. The middle of your lock is your centerpoint.
You set up two circles with that centerpoint as the middle. The outer circle the mousepointer need to be inside to turn the key.
The smaller the mousepointer must be outside to turn the key.
This will give you a track that the mousepointer can go around.
You can set up the circles with this function
Code: Select all
def inCircle(pointX, pointY,gX,gY,distance):
xDist = pointX-gX
xDist=math.fabs(xDist)
yDist = pointY-gY
yDist=math.fabs(yDist)
xyDist = (xDist*xDist)+(yDist*yDist)
if distance >= math.sqrt(xyDist):
return True
else:
return False
You need a label that repeats itself every 0.2 second (or something like that).
You need to check that the mousepointer is inside the track and the angle of the line between the centerpoint and the mousepointer.
You can get the angle with this.
Code: Select all
python:
mX=renpy.get_mouse_pos()[0]
mY=renpy.get_mouse_pos()[1]
xD = centerX-mX
yD = centerY-mY
turnDegree = math.degrees(math.atan2(yD, xD))+180
The turning starts when the mousepointer goes over the 0 point and continue as long as the degree keeps increasing, until a turn is completed and the door opens.
Not tested but I think it should work.
I will probably see if I can work something like this into my wip game.
- Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
- Contact:
Re: Circular QTE-like button press
I got interested enough to try out my idea and make a little video of my test, that now is in the cook book with the code for my script.
viewtopic.php?f=51&t=57267
Re: Circular QTE-like button press
Elegant. I hadn’t thought of using the pause command to essentially set up a polling loop. Kudos.
- Per K Grok
- Miko-Class Veteran
- Posts: 882
- Joined: Fri May 18, 2018 1:02 am
- Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
- itch: per-k-grok
- Location: Sverige
- Contact:
- Kinmoku
- Miko-Class Veteran
- Posts: 591
- Joined: Mon Aug 11, 2014 9:39 am
- Completed: One Night Stand
- Projects: VIDEOVERSE
- Tumblr: gamesbykinmoku
- itch: kinmoku
- Location: Germany
- Contact:
Re: Circular QTE-like button press
This is awesome! I got side-tracked and completely forgot I posted about this, but thank you for the help! I'll definitely be implementing this
Who is online
Users browsing this forum: Google [Bot], Majestic-12 [Bot]