Leridan's 'Play Instrument' Event
I see a lot of people ask how they can implement a way to allow the player to use an instrument in their game. A great example of this is the ocarina in The Legend of Zelda: Ocarina of Time
This event was created based on that concept. Using this feature, you can give the player an item that will allow them to press specific buttons that you designate to play musical notes. If the notes played match a predetermined pattern (i.e. a 'song'), you can turn a switch on to activate another event, such as clearing a pathway or opening a door. Turn the switch off when you're done and you can reuse it on another map.How it works:
Near the bottom of the event's code, you will see a section for the songs. The default song notes use the arrow keys, and each key has been assigned a number (up = 1, right = 2, down = 3, left = 4). You can use these notes to write your songs, or define your own keys instead. More songs can be added to the event by using the same formula.
To teach the player a new song, you will have to set up an event to initiate the process. All of this can be found in the demo. I have placed an NPC on the test map to show you how to set it up. You can use this example as a basis for teaching new songs.
Screenshots of the full code:
All necessary files are included in the download. The code has been commented to explain each part of the process.Version history:
- Added option to teach new songs via events.
- Added song list feature.
- Completed initial version.
This post has been edited by Leridan: Jun 9 2010, 03:56 AM