top of page
PingKang Chen's Blog
Project Name: Voice-Controlled Game
Demo video:
Overview:
Inspired by Super Mario, I developed a voice-controlled game in MATLAB, also including coding the background music to recreate the nostalgic 8-bit style. In this interactive game, the player needs to use their voice to control the duration and height of the character's jump. Sustain the voice to cross the gaps between lands and avoid falling into them. Adjust the volume of the voice to linearly control the jump's height for avoiding brick blocks and collecting gold coins appearing randomly in the air, while scoring points in the process. Failure to do so will result in a game over.
Game Flowchart:

Jump with linear height*:
Short-Term Energy (STE) will be employed, specifying the signal amplitude of a certain signal point over time. First, assess the STE. If it exceeds 80, set the energy equal to 80. Then, on the basis of a fixed jump height, add or subtract 1.5 times the STE to achieve linear jumping.
Coin Generation and Collection Logic*:
Firstly, in the 'init' initialization function, randomly generate the positions of the coins and record the central position of each coin along with the background matrix replaced by that coin. This information serves as the output returned by the 'init' function.
In the callback function of the timer, check if the center of the character overlaps with the center of any coin. If they overlap, consider the coin as collected. Replace the position of that coin in the background canvas with the matrix replaced during the initialization, completing the functionality for coin disappearance.
Materials (SFX, images):
Background music (Super Mario):
00:00 / 01:53
Game Over:
00:00 / 00:01

Background Map

jarvusJump.jpg

jarvusRun.jpg
Win:
00:00 / 00:03

gameover.jpg

win.jpg
Code for the Background Music:
Key Functions built for the Sound Synthesis:

drum track
melodys
bass
background music.wav
MATLAB Code for Background Music Generation:
The script responsible for generating the complete game:
Download the Code:
bottom of page