Hey everyone. I am currently working on my first game, a simple console text-based battle game. Well actually I just started it today and have already run into serveral obstacles. Here is the code so far
Code:
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <fstream.h>
using namespace std;
struct character
{ int hp;
int att;
int def;
int acc;
int eva;
int randomhit;
int hitdamage;};
int main()
{
ofstream a_file ( "explaination.txt" ); //opens explanation file
character player;
character enemy;
player.hp=500;
player.att=50;
player.def=45;
player.acc=25;
player.eva=12;
player.randomhit=rand()%18;
player.hitdamage=rand(45)%55;
enemy.hp=300;
enemy.att=35;
enemy.def=42;
enemy.acc=15;
enemy.eva=3;
enemy.randomhit=rand()%10;
enemy.hitdamage=rand(30)%45;
cout<<"You : "<<player.hp<<"";
cout<<"Enemy : "<<enemy.hp<<"";
cout<<"Will you....\n";
cout<<"1) Attack\n2) Defend\n";
cout<<"\nPlease make your descision\n";
return 0;
}
This is just the beggining and I know it's only very simple but once I get this one sorted I'll move on to more complexed games and then graphics, but back to the problem at hand :
Can someone please tell me why these error messages appear and how to fix them : (please)
54 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\bits\stl_algobase.h:67, from C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\memory In file included from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/bits/stl_algobase.h:67, from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/memory
48 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\memory:54, from C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\string from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/memory:54, from C:/PROGRAM FILES/DEV-CPP/include/c++/3.3.1/string
(There are more to this effect)
108 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\cstdlib `rand' not declared
27 C:\Program Files\Dev-Cpp\Templates\chrisbattle.cpp `rand' undeclared (first use this function)
2 C:\PROGRAM FILES\DEV-CPP\include\c++\3.3.1\backward\backward_warning.h: 32 #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
C:\Program Files\Dev-Cpp\Templates\chrisbattle.cpp In function `int main()':
Thanks