J
JoeC
I am writing a game and all my game pieces are stored in a single
vector of piece handles. I have the basics I can read and write char
and number files but I am trying to do comthing more complicated. I
am trying to save the data I need to save and I can fill in some when
the necessary data is saved.
Vector->piece handle -> pointer to the pieces. How do I go about
saving that data into a file. I have been doing some research to some
sites: http://www.angelfire.com/country/aldev0/cpphowto/
cpp_BinaryFileIO.html
I seem to get somthing to save. So far in my handle for the pieces I
have a save function that will have the pieces save themselvs. Here
is the data I want to save:
class unit{
protected:
coord loc;
coord currentLoc;
graphics * gr;
tbox * combatBox;
std::vector<color>colors;
float attack;
float dattack;
float defence;
More numbers...
Here is how I am starting:
void unit::write(std::fstream& f){
f.write((char*)&loc, sizeof (loc));
f.write((char*)&colors, sizeof (colors));
Am I going about it the right or wrong way?
vector of piece handles. I have the basics I can read and write char
and number files but I am trying to do comthing more complicated. I
am trying to save the data I need to save and I can fill in some when
the necessary data is saved.
Vector->piece handle -> pointer to the pieces. How do I go about
saving that data into a file. I have been doing some research to some
sites: http://www.angelfire.com/country/aldev0/cpphowto/
cpp_BinaryFileIO.html
I seem to get somthing to save. So far in my handle for the pieces I
have a save function that will have the pieces save themselvs. Here
is the data I want to save:
class unit{
protected:
coord loc;
coord currentLoc;
graphics * gr;
tbox * combatBox;
std::vector<color>colors;
float attack;
float dattack;
float defence;
More numbers...
Here is how I am starting:
void unit::write(std::fstream& f){
f.write((char*)&loc, sizeof (loc));
f.write((char*)&colors, sizeof (colors));
Am I going about it the right or wrong way?