-
August 23rd, 2009, 07:09 AM
#1
[HELP] First c++ text based game :)
Hi, this is both my first post here and my first c++ project
i have been wotking on a text based games in c++ but have a problem... i have tried to go back several times but cant seem to find the problem, so i thaught you guys could help me
here is the error i get when building:
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(6) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(7) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(8) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(9) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(10) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(11) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(12) : error C2143: syntax error : missing ';' before 'constant'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(13) : error C2143: syntax error : missing ';' before 'constant'
Code:
#include "library.h"
PLAYER::PLAYER()
{
strength 1;
intelligence 1;
gold 0;
experience 0;
health 25;
maxhealth 25;
mana 0;
maxmana 0;
}
void PLAYER::AddExperience(int amount)
{
SetExperience(experience + amount);
}
void PLAYER::AddGold(int amount)
{
SetGold(gold + amount);
}
void PLAYER::AddHealth(int amount)
{
SetHealth(health + amount);
}
void PLAYER::AddMana(int amount)
{
SetMana(mana + amount);
}
int PLAYER::GetGold()
{
return gold;
}
int PLAYER::GetHealth()
{
return health;
}
int PLAYER::GetIntelligence()
{
return intelligence;
}
int PLAYER::GetMana()
{
return mana;
}
int PLAYER::GetMaxHealth()
{
return maxhealth;
}
int PLAYER::GetMaxMana()
{
return maxmana;
}
char* PLAYER::GetName()
{
return name;
}
int PLAYER::GetStength()
{
return strength;
}
void PLAYER::SetExperience(int newexperience)
{
experience = newexperience;
//check for any level ups
}
void PLAYER::SetGold(int newgold)
{
gold = newgold;
}
void PLAYER::SetHealth(int newhealth)
{
health = newhealth;
if (health > maxhealth)
health = maxhealth;
if (health < 0)
health = 0;
}
void PLAYER::SetIntelligence(int newint)
{
intelligence = newint;
}
void PLAYER::SetMana(int newmana)
{
mana = newmana;
if (mana > maxmana)
mana = maxmana;
if (mana < 0)
mana = 0;
}
void PLAYER::SetMaxHealth(int newmaxhealth)
{
maxhealth = newmaxhealth;
}
void PLAYER::SetMaxMana(int newmaxmana)
{
maxmana = newmaxmana;
}
bool PLAYER::SetName(char *newname)
{
if (strlen(newname) == 0)
return false;
if (strlen(newname) > 32)
return false;
strcpy(name,newname);
return false;
}
void PLAYER::SetStrength(int newstr)
{
strength = newstr;
}
void PLAYER::LooseHealth(int amount)
{
SetHealth(health - amount);
}
void PLAYER::LooseMana(int amount)
{
SetMana(mana - amount);
}
int PLAYER::SpendGold(int amount)
{
SetGold(gold - amount);
}
thanks alot
-
August 23rd, 2009, 08:25 AM
#2
Re: [HELP] First c++ text based game :)
fixed this.... sorry for the double post... :S
-
August 23rd, 2009, 09:06 AM
#3
Re: [HELP] First c++ text based game :)
whats with this error exactly? :P
------ Build started: Project: DopeGame2, Configuration: Debug Win32 ------
Compiling...
Player.cpp
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(133) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
c:\program files\microsoft visual studio 9.0\vc\include\string.h(74) : see declaration of 'strcpy'
c:\users\eir\documents\visual studio 2008\projects\dopegame2\dopegame2\player.cpp(156) : error C4716: 'PLAYER::SpendGold' : must return a value
Build log was saved at "file://c:\Users\Eir\Documents\Visual Studio 2008\Projects\DopeGame2\DopeGame2\Debug\BuildLog.htm"
DopeGame2 - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Code:
#include "library.h"
PLAYER::PLAYER()
{
strength = 1;
intelligence = 1;
gold = 0;
experience = 0;
health = 25;
maxhealth = 25;
mana = 0;
maxmana = 0;
}
void PLAYER::AddExperience(int amount)
{
SetExperience(experience + amount);
}
void PLAYER::AddGold(int amount)
{
SetGold(gold + amount);
}
void PLAYER::AddHealth(int amount)
{
SetHealth(health + amount);
}
void PLAYER::AddMana(int amount)
{
SetMana(mana + amount);
}
int PLAYER::GetGold()
{
return gold;
}
int PLAYER::GetHealth()
{
return health;
}
int PLAYER::GetIntelligence()
{
return intelligence;
}
int PLAYER::GetMana()
{
return mana;
}
int PLAYER::GetMaxHealth()
{
return maxhealth;
}
int PLAYER::GetMaxMana()
{
return maxmana;
}
char* PLAYER::GetName()
{
return name;
}
int PLAYER::GetStength()
{
return strength;
}
void PLAYER::SetExperience(int newexperience)
{
experience = newexperience;
//check for any level ups
}
void PLAYER::SetGold(int newgold)
{
gold = newgold;
}
void PLAYER::SetHealth(int newhealth)
{
health = newhealth;
if (health > maxhealth)
health = maxhealth;
if (health < 0)
health = 0;
}
void PLAYER::SetIntelligence(int newint)
{
intelligence = newint;
}
void PLAYER::SetMana(int newmana)
{
mana = newmana;
if (mana > maxmana)
mana = maxmana;
if (mana < 0)
mana = 0;
}
void PLAYER::SetMaxHealth(int newmaxhealth)
{
maxhealth = newmaxhealth;
}
void PLAYER::SetMaxMana(int newmaxmana)
{
maxmana = newmaxmana;
}
bool PLAYER::SetName(char *newname)
{
if (strlen(newname) == 0)
return false;
if (strlen(newname) > 32)
return false;
strcpy(name,newname);
return false;
}
void PLAYER::SetStrength(int newstr)
{
strength = newstr;
}
void PLAYER::LooseHealth(int amount)
{
SetHealth(health - amount);
}
void PLAYER::LooseMana(int amount)
{
SetMana(mana - amount);
}
int PLAYER::SpendGold(int amount)
{
SetGold(gold - amount);
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|