Windows 7
Dev C++ version 4.9.9.2
Hello I am fallowing the wrath lands game creator tutorial and I am having the following problem.
Compiler: Default compiler
Building Makefile: "C:\Dev-Cpp\Proj\Nimph\Makefile.win"
Executing make...
make.exe -f "C:\Dev-Cpp\Proj\Nimph\Makefile.win" all
g++.exe main.o battle.o town.o crossroads.o helper.o player.o -o "Nimph.exe" -L"C:/Dev-Cpp/lib"
crossroads.o(.bss+0x0):crossroads.cpp: multiple definition of `player'
town.o(.bss+0x0):town.cpp: first defined here
player.o(.bss+0x0):player.cpp: multiple definition of `player'
town.o(.bss+0x0):town.cpp: first defined here
collect2: ld returned 1 exit status
make.exe: *** [Nimph.exe] Error 1
Execution terminated
Here are the files:
global.h:
#ifndef GLOBAL_DEFEINE
#define GLOBAL_DEFINE
//prototypes
void wait();
bool crossroads();
bool town(PLAYER*);
#endif
library.h:
#include <iostream>
using namespace std;
#include "player.h"
#include "globals.h"
PLAYER player;
player.h:
//player
class PLAYER
{
private:
char name[32];
int strength;
int intelligence;
int gold;
int experience;
int health;
int maxHealth;
int mana;
int maxMana;
int level;
public:
PLAYER();
bool setName (char* newName);
char* getName();
void setStrength (int newStr);
int getStrength();
void setIntelligence (int newInt);
int getIntelligence();
void setGold (int newGold);
void addGold (int amount);
void spendGold (int amount);
int getGold();
void setExperiance (int newExperiance);
void addExperiance (int amount);
int getExperiance();
void setHealth (int newHealth);
void addHealth (int value);
void loseHealth (int value);
int getHealth();
void setMaxHealth (int newMaxHealth);
int getMaxHealth();
void setMana (int newMana);
void addMana (int amount);
void loseMana(int amount);
int getMana();
void setMaxMana (int newMaxMana);
int getMaxMana();
};
crossroads.cpp
//crossroads
#include "library.h"
//Global Variables
bool glcomplete = false;
bool fcomplete = false;
bool scomplete = false;
bool gcomplete = false;
bool ccomplete = false;
//crossroads
bool crossroads()
{
int choice = 0;
while (choice != 10)
{
cout << "You stand at the corner of several roads going off in many directions.\n\n";
cout << "There is a small town behind you full of shops and people.\n";
cout << "Which path do you choose?\n";
cout << "1: Town\n";
cout << "2: Summoning Portal\n";
if (!glcomplete)
{
cout << "3: Grasslands (QUEST)\n";
}
if (glcomplete && !fcomplete)
{
cout << "4: Forest Road (QUEST)\n";
}
if (fcomplete && !scomplete)
{
cout << "5: Swamp Road (QUEST)\n";
}
if (scomplete && !gcomplete)
{
cout << "6: Graveyard Road (QUEST)\n";
}
if (gcomplete && !ccomplete)
{
cout << "7: Castle Road (QUEST)\n";
}
cout << "10: Exit Game\n";
cout << ">";
cin >> choice;
cout << endl;
switch (choice)
{
case 1:
{
cout << "You walk into the town.\n\n";
wait();
town(&player);
break;
}
case 2:
{
//summoningportal()
break;
}
case 3:
{
if (!gcomplete)
//grasslands()
break;
}
case 4:
{
if (glcomplete && !fcomplete)
//forest()
break;
}
case 5:
{
if (fcomplete && !scomplete)
//swamp()
break;
}
case 6:
{
if (scomplete && !gcomplete)
//graveyard()
break;
}
case 7:
{
if (gcomplete && !ccomplete)
//castle()
break;
}
default:
break;
}
}
return true;
}
town.cpp
//town
#include "library.h"
//Town Functions
void inn();
bool town(PLAYER*)
{
int choice = 0;
while (choice != 5)
{
cout << "You stand thn the middle of the town.\n";
cout << "All around you there are peeople going about their daily lives.\n";
cout << "To your left you spot an INN and to your right you spot the ARMORY and"
<< "\nITEM SHOP.\n\n";
wait();
cout << "What would you like to do?\n";
cout << "1: Enter INN\n";
cout << "2: Enter ARMORY\n";
cout << "3: Enter ITEM SHOP\n";
cout << "4: Check Stats\n";
cout << "5: Leave Town\n";
cout << ">";
cin >> choice;
cout << "\n";
switch (choice)
{
case 1:
{
//inn
break;
}
case 2:
{
//armory
break;
}
case 3:
{
//item shop
break;
}
case 4:
{
//stats
break;
}
default:
break;
}
}
return true;
}
void inn()
{
cout << "You stand in a small almost vancent inn. Exept for tan old man standing behind"
<< "\na counter there is no one else currently staying here.\n\n";
cout << "You walk over to the old man. He grins, delighted to see a visitor.\n"
<< "Hello and welcome, would you like to saty in my inn for only 10 gold coins?";
char answer[5];
while (answer[0] != 'y' || answer[0] != 'n')
{
cout << "Stay? (10 gold) y/n\n";
cin >> answer;
}
cout << endl;
if (answer[0] == 'y')
{
if (player.getGold() > 10)
{
player.spendGold(10);
cout << "You find a nice bed and fall; fast asleep.\n";
wait();
cout << "\n(HP and MP restored)/n\n";
cout << "HP: " << player.getHealth() << "/" << player.getMaxHealth();
cout << " MP: " << player.getMana() << "/" << player.getMaxMana();
player.setHealth (player.getMaxHealth());
player.setMana (player.getMaxMana());
wait();
}
else
{
cout << "It looks like you don't have enough gold.\n";
wait();
answer[0] = 'n';
}
}
if (answer[0] == 'n')
{
cout << "You turn around and walk out of the inn.\n";
}
}
and player.cpp
#include "library.h"
PLAYER::PLAYER()
{
strength = 1;
intelligence = 1;
gold = 0;
experience = 0;
health = 25;
maxHealth = 25;
mana = 0;
maxMana = 0;
}
void PLAYER::addExperiance(int amount)
{
setExperiance(experience + amount);
}
void PLAYER::addGold(int amount)
{
setGold(gold + amount);
}
void PLAYER::addHealth(int value)
{
setHealth(health + value);
}
void PLAYER::addMana(int amount)
{
setMana(mana + amount);
}
int PLAYER::getExperiance()
{
return experience;
}
int PLAYER::getGold()
{
return gold;
}
int PLAYER::getHealth()
{
return health;
}
int PLAYER::getMana()
{
return mana;
}
int PLAYER::getIntelligence()
{
return intelligence;
}
int PLAYER::getMaxHealth()
{
return maxHealth;
}
int PLAYER::getMaxMana()
{
return maxMana;
}
char* PLAYER::getName()
{
return name;
}
int PLAYER::getStrength()
{
return strength;
}
void PLAYER::setExperiance(int newExperiance)
{
experience = newExperiance;
//check for 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 true;
}
void PLAYER::setStrength(int newStr)
{
strength = newStr;
}
void PLAYER::loseHealth(int amount)
{
setHealth(health - amount);
}
void PLAYER::loseMana(int amount)
{
setMana(mana - amount);
}
void PLAYER::spendGold(int amount)
{
setGold(gold - amount);
}
If anyone could help me it would be greatly appreciated.