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.
