Created
August 8, 2015 14:01
-
-
Save jkramarz/0220fa0d9d2bd45ef3db to your computer and use it in GitHub Desktop.
guitarhero
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cctype> | |
#include <cstdlib> | |
using namespace std; | |
bool game = false; | |
string colors[] = {"pink", "blue", "red", "yellow", "green"}; | |
int actual = 0; | |
int points = 0; | |
void intro(){ | |
cout << "Guitar Hero I" << endl; | |
cout << "Copytight (c) 1982 Activision" << endl; | |
cout << "All rights reserved." << endl; | |
cout << endl; | |
cout << "Nightclub" << endl; | |
cout << "You are standing in a nightclub." << endl; | |
cout << "There is a ::guitar:: here." << endl; | |
cout << endl; | |
cout << "> "; | |
} | |
void help(){ | |
cout << endl; | |
cout << "Available commands:" << endl; | |
cout << " look at ::something::" << endl; | |
cout << " take ::something::" << endl; | |
cout << " exit" << endl; | |
cout << endl; | |
cout << "> "; | |
} | |
void help_game(){ | |
cout << endl; | |
cout << "Available commands:" << endl; | |
cout << " press pink/blue/red/yellow/green button" << endl; | |
cout << " exit" << endl; | |
cout << endl; | |
cout << "> "; | |
} | |
void take(){ | |
cout << "You have taken the ::guitar::" << endl; | |
} | |
void generate(){ | |
actual = rand() % 5; | |
cout << "You see " + colors[actual] + " circle." << endl; | |
cout << endl; | |
cout << "> "; | |
} | |
void nothing(){ | |
cout << "Do... what?!" << endl; | |
cout << endl; | |
cout << "> "; | |
} | |
void init(){ | |
game = true; | |
} | |
void look(){ | |
cout << "The ::guitar:: has ::pink::, ::blue::, ::red::, ::yellow::, and ::green:: buttons." << endl; | |
cout << endl; | |
cout << "> "; | |
} | |
void fail(){ | |
cout << "You failed!" << endl; | |
} | |
void exit(){ | |
cout << "You have reached " << points << " points." << endl; | |
} | |
int main(){ | |
intro(); | |
while(true){ | |
string command; | |
getline(cin,command); | |
for(unsigned int i = 0; i < command.length(); i++) | |
command[i] = tolower(command[i]); | |
if(!game){ | |
if(command == "help" or command == "" or command == "?") | |
help(); | |
else if(command == "take guitar"){ | |
take(); | |
help_game(); | |
init(); | |
generate(); | |
}else if(command == "look at guitar") | |
look(); | |
else if(command == "exit") | |
break; | |
else | |
nothing(); | |
}else{ | |
if(command == "help") | |
help_game(); | |
else{ | |
if(command == "press " + colors[actual] + " button"){ | |
if(points++ == 50) | |
cout << "You're still playing Guitar Hero, but you've lost The Game!" << endl; | |
generate(); | |
}else if (command == "exit"){ | |
break; | |
}else{ | |
fail(); | |
break; | |
} | |
} | |
} | |
} | |
exit(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment