Hey Guys
I'm new to programming and also new to this forum.
Having a little trouble passing arguments to functions.
I wrote this simple program to help me get the hang of it but I'm quite stuck. I'm sure you will be able to get at what i want the program to do... could someone please tell me where i'm going wrong?
Thanks in advance
Code:
#include <conio.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>
void menu(int HP,int Gold,int Armour);
void HealthPosion(int HP);
void BuyArmour(int Gold, int Armour);
void GoblinAttack(int HP);
void NewGame(int HP,int Gold,int Armour);
void DisplayInfo(int HP,int Gold,int Armour);
void pause();
main()
{
int Gold;
int HP;
int Armour;
menu(HP, Gold, Armour);
return 0;
}
void menu(int HP,int Gold,int Armour)
{
int menuRep=1;
int menuOption;
do
{
system("cls");
printf("\t\tDRAGON HUNTER\n");
printf("--------------------------\n\n");
printf("1] NEW GAME....\n\n");
printf("2] DRINK HEALTH POSION....\n\n");
printf("3] BUY SOME ARMOUR....\n\n");
printf("4] GET ATTACKED BY A GOBLIN....\n\n");
printf("5] DISPLAY PLAYER INFO....\n\n");
printf("6] Exit....\n\n");
printf("please select an option....\n");
scanf("%d",&menuOption);
switch(menuOption)
{
case 1:
system("cls");
printf("\t NEW GAME....\n");
printf("-----------------------------\n\n");
NewGame(HP,Gold,Armour);
pause();
break;
case 2:
printf("DRINK HEALTH POSION....\n");
printf("-------------------------------------------------\n");
HealthPosion(HP);
pause();
break;
case 3:
printf("\tBUY SOME ARMOUR....\n");
printf("-------------------------------------------------\n");
BuyArmour(Gold, Armour);
pause();
break;
case 4:
printf("\t\tGET ATTACKED BY A GOBLIN....\n");
printf("-----------------------------------\n");
GoblinAttack(HP);
pause();
break;
case 5:
printf("\t\tDISPLAY PLAYER INFO....\n");
printf("-----------------------------------\n");
DisplayInfo(HP,Gold,Armour);
pause();
break;
case 6:
menuRep=0;
break;
}
}
while(menuRep==1);
}
void NewGame(int HP,int Gold,int Armour)
{
HP=100;
Gold=50;
Armour=2;
}
void HealthPosion(int HP)
{
HP=HP+10;
}
void BuyArmour(int Gold, int Armour)
{
Gold=Gold-5;
Armour=Armour+2;
}
void GoblinAttack(int HP)
{
HP=HP-10;
}
void DisplayInfo(int HP,int Gold,int Armour)
{
system("cls");
printf("GOLD:%d\nHP:%d\nArmour:%d\n\n\n\n", Gold,HP,Armour);
pause();
}
void pause()
{
system("pause");
}
(Hope im doing the tags right :/)