XDatUrFace ☆
Join date : 2013-01-06 Posts : 126
| Subject: Fantasica Fan Game/Parody! Sat May 31, 2014 10:10 pm | |
| So I'm a college student and I had some programming homework to do ... and I decided to have some fun with it! The assignment was to create some sort of virtual pet game on the windows console. So, instead of doing the assignment properly like I should have, I based the game scenario on the current Fantasica event School Daze: - Quote :
- Lepre, Mao, and Cane need cherries to cheer them up against the demons! You have 10 cherries to start with and gain an additional 5 each day. If a girl's love level goes to zero or below, they will hate you! Be careful! Their love level decreases by 3 each day. Try to get their love level to over 15 by day 10!
The source code, in C++, is included in the spoiler-thingy below. I haven't uploaded an executable and I probably won't because everyone would think it's a virus. You can compile the code by downloading any free C++ compiler/IDE out there. You can also search for an online compiler and copypasta the code, but it won't support any user input. - Sample output:
F A N T A S I C A S C H O O L D A Z E
Lepre, Mao, and Cane need cherries to cheer them up against the demons! You have 10 cherries to start with and gain an additional 5 each day. If a girl's love level goes to zero or below, they will hate you! Be careful! Their love level decreases by 3 each day. Try to get their love level to over 15 by day 10!
======= Day 1 You have 10 cherries. give Lepre: You forgot about Lepre. Lepre has love level 0 and hates you. You have 10 cherries. give Mao: You forgot about Mao. Mao has love level 0 and hates you. You have 10 cherries. give Cane: You forgot about Cane. Cane has love level 0 and hates you. ======= Day 2 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 3 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 4 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 5 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 6 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 7 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 8 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Day 9 Lepre still hates you. Mao still hates you. Cane still hates you. ======= Someone else stole the heart of Lepre Someone else stole the heart of Mao Someone else stole the heart of Cane The End
- Source code:
#include <iostream> #include <string>
using namespace std;
int cherries = 10; int amount_gift;
class bish { public: bish(string name, int level); void gift(int amt); void apart(); string name() const; int level() const; bool ishate() const; bool islove() const; private: string u_name; int u_level; };
bish::bish(string nm, int initialLevel) { u_name = nm; u_level = initialLevel; }
void bish::gift(int amt) { u_level += amt; }
void bish::apart() { u_level -= 3; }
string bish::name() const { return u_name; }
int bish::level() const { return u_level; }
bool bish::ishate() const { if (u_level < 1) return true; else return false; }
bool bish::islove() const { if (u_level > 15) return true; else return false; }
void reportStatus(const bish* p) { cout << p->name() << " has love level " << p->level(); if (p->ishate()) cout << " and hates you."; if (p->islove()) cout << " and loves you."; cout << endl; }
//gameplay void carefor(bish* p, int d) { if (p->ishate()) { cout << p->name() << " still hates you." << endl; return; }
cout << "You have " << cherries << " cherries.\n" << "give " << p->name() << ": "; cin >> amount_gift; if (amount_gift > 0 && amount_gift <= cherries) { p->gift(amount_gift); cherries -= amount_gift; cout << "You gave " << p->name() << " " << amount_gift << " cherries.\n"; } else if (amount_gift == 0) cout << "You forgot about " << p->name() << ".\n"; else cout << "You tried to cheat. No cherries were give to " << p->name() << ".\n";
p->apart(); reportStatus(p); }
int main() { //Instructions cout << "F A N T A S I C A" << endl << "S C H O O L D A Z E" << endl << endl; cout << "Lepre, Mao, and Cane need cherries to cheer them up against the demons! \n" << "You have 10 cherries to start with and gain an additional 5 each day. \n" << "If a girl's love level goes to zero or below, they will hate you! \n" << "Be careful! Their love level decreases by 3 each day. \n" << "Try to get their love level to over 15 by day 10! \n" << endl << endl;
//initialize bish* myBish[3]; myBish[0] = new bish("Lepre", 3); myBish[1] = new bish("Mao", 3); myBish[2] = new bish("Cane", 3);
//gamestart for (int day = 1; day <= 9; day++) { cout << "======= Day " << day << endl; for (int k = 0; k < 3; k++) carefor(myBish[k], day); cherries += 5; }
//gameend cout << "=======" << endl; //results for (int k = 0; k < 3; k++) { if (myBish[k]->ishate()) cout << "Someone else stole the heart of " << myBish[k]->name() << endl; else if (myBish[k]->islove()) cout << myBish[k]->name() << " wants to be with you forever." << endl; delete myBish[k]; } cout << "The End"; }
Copypasting the code made the indentations disappear ... and I was too lazy to change it. | |
|