Code:
#include <stdio.h>
int get_choice( void ){
int choice;
printf("?:: ");
scanf("%d", &choice);
return( choice );
}
int show_stats( hp, tired, cash, karma ){
printf("\n\n::Stats::\n|%d HP|\n|%d Awake|\n|$%d Cash|\n|%d Karma|\n\n", hp, tired, cash, karma);
return 0;
}
int show_stats_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
printf("\n\n::Stats::\n|%d HP|\n|%d Awake|\n|$%d Cash|\n|%d Karma|\n\n", hp, tired, cash, karma);
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int show_time( timehh, timeh, timem, timemm ){
if( timeh >= 10 ){
timeh = timeh - 10;
timehh = timehh + 1;
}
printf("\n|%d%d:%d%d|\n", timehh, timeh, timem, timemm);
return 0;
}
int show_time_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
if( timeh >= 10 ){
timeh = timeh - 10;
timehh = timehh + 1;
}
printf("\n|%d%d:%d%d|\n", timehh, timeh, timem, timemm);
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int get_score( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
int _score;
int _score1;
int _score2;
_score1 = cash * hp;
_score2 = tired - karma;
_score = _score1 + _score2;
printf("\nScore:: %d\n", _score);
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
printf("\n-|HOME|-\n1.Stats\n2.Time\n3.Activity\n4.Score\n5.Exit\n");
switch( get_choice() ){
case 1: show_stats_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 2: show_time_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 3: activities( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 4: get_score( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 5:
break;
}
}
int activities( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
printf("\n\n-|Activities|-\n1.Go to Church\n2.Go for a walk\n3.Go to the shop\n4.Battle\n");
switch( get_choice() ){
case 1: place_church_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 2: activity_walk_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 3: place_shop_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 4: activity_battle( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
}
}
int item_newspaper( void ){
printf("\n\n-|ASCII TIMES|-\nMISSING LINK FOUND!\nExperts at cambrige university\nhave found the missing\nlink to the mystery of evolution!\nThey say that we were once monkeys.\nAnd before monkeys we were dumb...\nBy Ben Dover\n\n");
}
int place_church( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
printf("\n\nYou get into your car and drive to Church...\n-20 Karma\n\n");
karma = karma - 20;
printf("\nThe Church band starts to play a song that you like..\nYou don't usually sing but this is a long time favourite of yours...\n1.Sing\n2.Don't sing\n");
switch( get_choice() ){
case 1: printf("\n\nYou start to sing...\nYou don't know the words that well...\n-10 Karma\n-10 Awake\n");
break;
case 2: printf("You try not to sing...\nYou can't help but tap your feet...\n\n");
break;
}
printf("\nThere is about to be Holy Communion...\nWill you take it??\n1.Yes\n2.No\n");
switch( get_choice() ){
case 1: printf("\nYou go up and take Holy Communion...\n-20 Karma\n+20 HP\n-5 Awake\n\n");
break;
case 2: printf("\nYou stay seated and seem to be the odd one out...\n\n");
break;
}
timeh = timeh + 1;
if( timeh >= 10 ){
timeh = timeh - 10;
timehh = timehh + 1;
}
show_time( timehh, timeh, timem, timemm );
return( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int place_church_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
printf("\n\nYou get into your car and drive to Church...\n-20 Karma\n\n");
karma = karma - 20;
printf("\nThe Church band starts to play a song that you like..\nYou don't usually sing but this is a long time favourite of yours...\n1.Sing\n2.Don't sing\n");
switch( get_choice() ){
case 1: printf("\n\nYou start to sing...\nYou don't know the words that well...\n-10 Karma\n-10 Awake\n");
break;
case 2: printf("You try not to sing...\nYou can't help but tap your feet...\n\n");
break;
}
printf("\nThere is about to be Holy Communion...\nWill you take it??\n1.Yes\n2.No\n");
switch( get_choice() ){
case 1: printf("\nYou go up and take Holy Communion...\n-20 Karma\n+20 HP\n-5 Awake\n\n");
break;
case 2: printf("\nYou stay seated and seem to be the odd one out...\n\n");
break;
}
timeh = timeh + 1;
if( timeh >= 10 ){
timeh = timeh - 10;
timehh = timehh + 1;
}
show_time( timehh, timeh, timem, timemm );
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int activity_walk( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
int moneyfound;
int moneygive;
moneyfound = hp * (tired - karma);
moneygive = ( cash / 4 ) - karma;
printf("\n\nYou walk dow the footpath for a while and find $%d!\n\n", moneyfound);
printf("You walk a bit further and see a bum with a sign that says:\n'HUNGRY! NEED MUNY 4 FOOD!'\n1.Give money\n2.Don't give money\n");
switch( get_choice() ){
case 1: printf("\nYou give the bum $%d\n'THANK YOU!'", moneygive);
karma = karma - 10;
printf("\n-10 Karma\n");
break;
default: printf("\nHe'll be going hungry tonight...\n\n");
break;
}
timem = timem + 3;
if( timem >= 6 ){
timem = timem - 6;
timeh = timeh + 1;
}
return( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int activity_walk_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
int moneyfound;
int moneygive;
moneyfound = hp * (tired - karma);
moneygive = ( cash / 4 ) - karma;
printf("\n\nYou walk dow the footpath for a while and find $%d!\n\n", moneyfound);
cash = cash + moneyfound;
printf("You walk a bit further and see a bum with a sign that says:\n'HUNGRY! NEED MUNY 4 FOOD!'\n1.Give money\n2.Don't give money\n");
switch( get_choice() ){
case 1: printf("\nYou give the bum $%d\n'THANK YOU!'", moneygive);
karma = karma - 10;
cash = cash - moneygive;
printf("\n-10 Karma\n");
break;
default: printf("\nHe'll be going hungry tonight...\n\n");
break;
}
timem = timem + 3;
if( timem >= 6 ){
timem = timem - 6;
timeh = timeh + 1;
}
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
place_shop( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
show_stats( hp, tired, cash, karma );
printf("\nWelcome to FoodMart\n\n");
printf("This is what we have in stock:\n1.Water $30\n2.Coke $100\n3.Pie $1000\n4.Mc........burger $2000\n");
switch( get_choice() ){
case 1: printf("\n\nBought water...\n+20 HP\n+20 Awake\n\n");
cash = cash - 30;
hp = hp + 20;
tired = tired + 20;
break;
case 2: printf("\n\nBought Coke...\n+30 HP\n+40 Awake\n\n");
cash = cash - 100;
hp = hp + 30;
tired = tired + 40;
break;
case 3: printf("\n\nBought Pie...\n+300 HP\n+300 Awake\n\n");
cash = cash - 1000;
hp = hp + 300;
tired = tired + 300;
break;
case 4: printf("\n\nBought Mc........burger\n+600 HP\n+200\n\n");
cash = cash - 2000;
hp = hp + 600;
tired = tired + 200;
break;
}
timem = timem + 3;
if( timem >= 6 ){
timem = timem - 6;
timeh = timeh + 1;
}
printf("Is that all?\n1.Yes\n2.No\n");
switch( get_choice() ){
case 1:
break;
case 2: place_shop( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
}
}
place_shop_menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
show_stats( hp, tired, cash, karma );
printf("\nWelcome to FoodMart\n\n");
printf("This is what we have in stock:\n1.Water $30\n2.Coke $100\n3.Pie $1000\n4.Mc........burger $2000\n");
switch( get_choice() ){
case 1: printf("\n\nBought water...\n+20 HP\n+20 Awake\n\n");
cash = cash - 30;
hp = hp + 20;
tired = tired + 20;
break;
case 2: printf("\n\nBought Coke...\n+30 HP\n+40 Awake\n\n");
cash = cash - 100;
hp = hp + 30;
tired = tired + 40;
break;
case 3: printf("\n\nBought Pie...\n+300 HP\n+300 Awake\n\n");
cash = cash - 1000;
hp = hp + 300;
tired = tired + 300;
break;
case 4: printf("\n\nBought Mc........burger\n+600 HP\n+200\n\n");
cash = cash - 2000;
hp = hp + 600;
tired = tired + 200;
break;
}
timem = timem + 3;
if( timem >= 6 ){
timem = timem - 6;
timeh = timeh + 1;
}
printf("Is that all?\n1.Yes\n2.No\n");
switch( get_choice() ){
case 1:
break;
case 2: place_shop( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
}
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int activity_battle( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
int youhit;
int gethit;
youhit = rand(10);
gethit = rand(10);
printf("%d-%d", youhit, gethit);
}
void adventure_begin( void ){
char name[10];
int timehh = 0;
int timeh = 8;
int timem = 0;
int timemm = 5;
printf("\nWhat is your name?\n?:");
scanf("%s", &name);
printf("\nOk, your name is %s.\n", name);
printf("You are 25 and live by yourself in a 1 bedroom house\n");
printf("\n|%d%d:%d%d\n|Sunday\n|Bedroom\n|Sleeping...\n\n", timehh, timeh, timem, timemm);
printf("Sunday morning...\n\n");
printf("1.Get up\n");
timem = timem + 2;
if( timem >= 6 ){
timem = timem - 6;
timeh = timeh + 1;
}
switch( get_choice() ){
case 1: adventure_1( name, timehh, timeh, timem, timemm );
break;
}
}
int adventure_1( name, timehh, timeh, timem, timemm ){
int hp = 50;
int tired = 50;
int cash = 100;
int karma = 0;
printf("\nYou are feeling a bit hungry. You have some cereal in your pantry.\n");
printf("1.Korn Flayks\n2.Coco Pops\n3.All Bran\n4.Dont eat\n");
switch( get_choice() ){
case 1: tired = tired + 30;
hp = hp + 30;
printf("\n+30 Awake\n+30 HP\n");
break;
case 2: tired = tired + 30;
hp = hp + 10;
printf("\n+30 Awake\n+10 HP\n");
break;
case 3: tired = tired + 10;
hp = hp + 50;
printf("\n+10 Awake\n+50 HP\n");
break;
case 4: printf("\nThat could cause some problems later %s..\n", name);
break;
}
timemm = timemm + 5;
if( timemm >= 10 ){
timemm = timemm - 10;
timem = timem + 1;
}
show_time( timehh, timeh, timem, timemm );
show_stats( hp, tired, cash, karma );
adventure_2( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
int adventure_2( name, hp, tired, karma, cash, timehh, timeh, timem, timemm ){
printf("You finish your breakfast and walk to the front door...\n");
printf("The paperboy rides past and throws you the paper...\n");
switch( tired ){
case 60: printf("You catch it one handed...\n\n");
break;
case 80: printf("You catch it one handed...\n\n");
break;
default: printf("You struggle to see it as it comes towards you...\nIt hits you in the forehead\n\n");
break;
}
printf("Would you like to read the newspaper??\n1.Read it\n2.Don't read it\n");
switch( get_choice() ){
case 1: item_newspaper();
break;
}
timemm = timemm + 5;
if( timemm >= 10 ){
timemm = timemm - 10;
timem = timem + 1;
}
show_time( timehh, timeh, timem, timemm );
printf("\n\nYou can't just do nothing all day..\nHere's what you can do at this morning:\n1.Go to Church\n2.Go for a walk\n3.Go to the shop\n");
switch( get_choice() ){
case 1: place_church( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 2: activity_walk( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
case 3: place_shop( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
break;
}
menu( name, hp, tired, karma, cash, timehh, timeh, timem, timemm );
}
main()
{
int choice;
printf("\n\nWelcome to ASCII RPG!\n\n1.Play\n2.Exit\n");
/*Begin Adventure*/
switch( get_choice() ){
case 1: adventure_begin();
break;
}
}