Skip to content

Instantly share code, notes, and snippets.

@Gi133
Created November 9, 2011 16:29
Show Gist options
  • Select an option

  • Save Gi133/1351980 to your computer and use it in GitHub Desktop.

Select an option

Save Gi133/1351980 to your computer and use it in GitHub Desktop.
Tomogachi thingy
// Stuff
#include <iostream>
#include <windows.h>
#include <string>
#include <conio.h>
#include <time.h>
#include <windows.h>
using namespace std;
enum state {WellFed, Peckish, Hungry, Starving, Dead};
void gotoxy ( short x, short y )
{
COORD coord = {x, y};
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
}
void clearscreen()
{
gotoxy(0,1);
for(int i=0; i<25; i++)
{
cout<<" ";
}
gotoxy(0,2);
for(int j=0; j<10; j++)
{
cout<<" ";
}
}
int main()
{
//Declerations
state s;
int food=100;
string action;
char key;
cout<<"Commands: K to kill, F to feed, P to pet";
while (food>=0)
{
if (food>=75)
{
s=WellFed;
}
if (food>=50 && food<75)
{
s=Peckish;
}
if (food>=25 && food<50)
{
s=Hungry;
}
if (food>=1 && food<25)
{
s=Starving;
}
if (_kbhit())
{
key = toupper(_getch());
if (key=='F')
{
food=food+10;
}
if (key=='K')
{
food=1;
}
}
switch(s)
{
case 0:
clearscreen();
gotoxy(0,1);
cout<< "Pet is Well Fed";
cout<< "\n";
cout<< "Food: "<<food;
cout<< "\n";
break;
case 1:
clearscreen();
gotoxy(0,1);
cout<< "Pet is Slightly Peckish";
cout<< "\n";
cout<< "Food: "<<food;
cout<< "\n";
break;
case 2:
clearscreen();
gotoxy(0,1);
cout<< "Pet is Hungry";
cout<< "\n";
cout<< "Food :"<<food;
cout<< "\n";
break;
case 3:
clearscreen();
gotoxy(0,1);
cout<< "Pet is Starving!";
cout<< "\n";
cout<< "Food: "<<food;
cout<< "\n";
}
Sleep(100);
food=food-1;
}
if (food<=0)
{
cout << "\n\n\n DEAD";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment