Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created August 3, 2012 21:09
Show Gist options
  • Save TooTallNate/3251558 to your computer and use it in GitHub Desktop.
Save TooTallNate/3251558 to your computer and use it in GitHub Desktop.
The "Kart Randomizer": mode, characters, and levels randomizer for Mario Kart 64
var characters = [
'Donkey Kong',
'Wario',
'Mario',
'Luigi',
'Peach',
'Toad',
'Bowser',
'Yoshi'
];
var ccs = [
'50cc',
'100cc',
'150cc',
'Extra'
];
var levels = [
'Luigi Raceway',
'Moo Moo Farm',
'Koopa Troopa Beach',
'Kalimari Desert',
'Toad\'s Turnpike',
'Frappe Snowland',
'Choco Mountain',
'Mario Raceway',
'Wario Stadium',
'Sherbet Land',
'Royal Raceway',
'Bowser\'s Castle',
'D.K.\'s Jungle Parkway',
'Yoshi Valley',
'Banshee Boardwalk',
'Rainbow Road'
];
// keep a mutable clone of the levels, so that we don't run into duplicates
var currentLevels = levels.slice();
function random (set) {
return set[set.length * Math.random() | 0];
}
function randomAndRemove (set) {
var val = random(set);
set.splice(set.indexOf(val), 1);
return val;
}
console.log('\033[1m\033[33mMode\033[39m:\033[22m %s', random(ccs));
console.log('\033[1m\033[36mPlayer 1\033[39m:\033[22m %s', randomAndRemove(characters));
console.log('\033[1m\033[31mPlayer 2\033[39m:\033[22m %s', randomAndRemove(characters));
console.log('\033[1m\033[32mPlayer 3\033[39m:\033[22m %s', randomAndRemove(characters));
console.log('\033[1m\033[34mPlayer 4\033[39m:\033[22m %s', randomAndRemove(characters));
getLevel();
function getLevel () {
if (currentLevels.length === 0) {
currentLevels = levels.slice();
}
console.log('\033[1mLevel:\033[22m %s', randomAndRemove(currentLevels));
}
process.stdin.setRawMode(true);
process.stdin.on('data', function (b) {
if (b[0] == 3 || b[0] == 4) {
// quit upon Ctrl+C or Ctrl+D
return process.stdin.pause();
}
getLevel();
});
process.stdin.resume();
@TooTallNate
Copy link
Author

Quick little 5-minute program for the office.

Example output:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment