This topic is really close to one I've been working on for a while.I was hoping that you guys could help me out.I'm trying to get my stats taken from my characters txt files and have the stats place onscreen.Which sounds pretty similar to what's going on.I thought I had it with my last attempt but there were far too many errors when I finally compiled it.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 2D project that uses Dark GDK
// it can be used as a starting point in making your own 2D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include <iostream>
#include <fstream>
using namespace std; //not sure if this is needed... just trying it out
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
// a call is made to this function so we can stop the GDK from
// responding to the escape key, we can then add in some code in our
// main loop so we can control what happens when the escape key is pressed
dbDisableEscapeKey ( );
//dbLoadImage ( "backdrop.bmp", 1 );
// the next step is to create a sprite that uses this image, this
// is achieved by calling dbSprite and passing in a value of 1 for the
// sprites ID, 0 for the X coordinate, 0 for the Y coordinates and a
// value of 1 for the image
//dbSprite ( 1, 0, 0, 1 );
// next we will load in some animated sprites, before doing this
// we need to adjust the image color key, by using this function we
// can make a specific color be transparent, in our case we want this
// to be bright pink
dbSetImageColorKey ( 255, 0, 255 );
fstream InFile;
char *Buffer;
//PIcked a safe number
int Length = 150;
int charisma,intelligence,character,reputation,joy;
//this line tell the program what text file to read.The ios::in tells it that we want to read from not write in this file
InFile.open("Anko.txt",ios::in);
//Test to see if we can access the file and if not give a error message
if(InFile.fail())
{
cout <<"Could not open Anko.txt" <<endl;
exit(1);
}
//Got to remember how you make the file.I did mine with string: number
char *MyString[];
char currentLetter;
char nextLetter;
int n;
while(!InFile.fail())
{
for(n=0;n < Length ;n++)
{
currentLetter = MyString[n];
nextLetter = MyString[n+1];
while(nextLetter != " ")
{
InFile >> currentLetter;
cout << currentLetter;
}
//If we run into a semicolon in our text file we've reached the end of the line
if(nextLetter == " " && currentLetter == ";")
{
cout <<endl;
}
}
InFile.close();
// MyStat = dbReadLong(1); //Reaad File and rettirns WORD
// dbPrint(MyStat);
while ( LoopGDK ( ) )
{
// here we check if the escape key has been pressed, when it has
// we will break out of the loop
if ( dbEscapeKey ( ) )
break;
// here we make a call to update the contents of the screen
dbSync ( );
}
return;
}
and the Anko.txt file
Name: Anko;
charisma:35;
Intelligence:25;
character:50;
Joy:15;
Largely it's acting like it's totally wrong to use =,==,!=, when dealing with char data.That's basically the kind of errors I get when I compile it.But if not that then what?Am I totally off base or what?
It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.