XaiJu
__ess__
__ess__

patreon


Ren'Py Piano/Keyboard Minigame Puzzle Script

Hello dear patrons! Hope you're doing well and that your projects are coming along nicely!

Today I have a new script for you, which is a little piano/keyboard puzzle where the goal is to press a combination of notes to unlock something, like a door. But you could modify and use the code however you wish.

How it works

The minigame is pretty basic and not really realistic. It has no way of detecting how long you press a key for, and it only plays a note once the mouse button is released on a key (keys are imagebuttons). I recorded the notes myself, and you may use them in your game if you want.

The white and black keys are separated into two hboxes, so that the black keys can overlap the white ones. They are added using imagebuttons within loops, so we don't have to write out code for each 25 keys ourselves. Then the actions that play when pressed are:

Play() - which plays the sound of the current key pressed from the key folder in the audio folder.

Function() - which runs a function called "pressed_key" that checks what key was pressed and if it's the correct key in the correct key combo sequence.

I also made a simple example of how you could have a paper note that gives a hint of how to win the minigame. It will show if a variable "has_hint" is True in the minigame and is a draggable that you can move around. It has it's own screen (view_hint) that is included into the minigame screen, only if the variable is True.

The text displayable in that screen uses a formatted string which uses the Python function "join()" to join the individual list elements of the correct key combination (correct_key_combo) into one string:

text "%s" % ", ".join(correct_key_combo)

The minigame will also show you what notes you have pressed on the little display to make it easier for the player.

The script have been commented as usual to let you know what everything does. If you still have questions after looking through it, you can leave them in the comments here or send me a message.

Enjoy! 😊⭐

Comments

I look forward to using this in my VN. Thank you for making amazing scripts Ess <3

Akouo Studios

I'm glad you like it! 😊

Sara

Wow... just wow! This tutorial is amazing!!!

Pytem


More Creators