hey i am making an rpg ascii game and my switches arent working even if i change them to ifs...... plz help
Code:
#include <stdio.h>
/*Gets user's answer to a question*/
int get_chioce( void ){
int choice;
printf("?:: ");
scanf("%d", &choice);
return( choice );
}
void show_stats( hp, tired ){
printf("\n::Stats::\n|%d HP|\n|%d Awake|\n", hp, tired);
}
void adventure_begin( void ){
char name[10];
int choice;
int timeh = 8;
int timem = 0;
int timemm = 5;
char ampm[2];
ampm[1] = 'a';
ampm[2] = 'm';
printf("\nWhat is your name?\n?:");
scanf("%s", &name);
printf("Ok, 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%s\n|Sunday\n|Bedroom\n|Sleeping...\n\n", timeh, timem, timemm, ampm);
printf("Adventure begins on a Sunday morning...\n");
printf("1.Get up\n");
get_chioce();
if( choice=1 ){
adventure_1( name );
}
}
int adventure_1( name ){
int timeh = 8;
int timem = 2;
int timemm = 5;
char ampm[2];
ampm[1] = 'a';
ampm[2] = 'm';
int choice;
int hp = 100;
int tired = 50;
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");
get_chioce();
switch( choice ){
case 1: tired = tired + 30;
break;
case 2: tired = tired + 20;
break;
case 3: tired = tired + 50;
break;
case 4: printf("\nThat could cause some problems later %s..\n", name);
break;
}
show_stats( hp, tired );
}
main()
{
int choice;
printf("\n\nWelcome to ASCII Adventure!\n\n1.Play\n2.Exit\n");
get_chioce();
/*Begin Adventure*/
switch( choice ){
case 1: adventure_begin();
break;
}
}
im only 13 too so not too experienced in this:P