i guess i tye that out a little to fast forgot one part, I am trying to move that part of the code to it's ove cpp and h file, my main file is
#include "stdafx.h"
#include "Dragon_Warrior.h"
//enum tKey Key[1];
void DarkSDK ( void )
{
// set varibles
Setup();
// Load media
LoadMedia();
// loop until the escape key is pressed
while ( LoopSDK() )
{
//When esc key pressed leave while loop.
if(dbEscapeKey()) return;
// Check For Key Presses
KeyCheck ( );
// Do Intro
if ( GameState == "Intro")
{
// start intro
intro ( );
}
if ( GameState == "Normal")
{
//
}
if ( GameState == "Battle")
{
//
}
if ( GameState == "Pause")
{
// Pause state
}
if ( GameState == "Over")
{
// This will be the ending screen.
}
EndRender();
}
}
void Setup ( void )
{
// SET FONT AND TEXT SIZE
dbSetTextFont ("Dwarrior");
dbSetTextSize ( 15 );
// get the size of half the screen
X_Screen = dbScreenWidth () / 2;
Y_Screen = dbScreenHeight () / 2;
// set the temps to zero
Y_Temp = 0;
X_Temp = 0;
TempNameNum = 1;
// set sync on and sync rate to 60 frames per second
dbSyncOn ( );
//dbSetDir("D:\Engine\Dragon_Warrior\Game");
dbLoadImage ( "Images\logo.bmp", 1, 1 );
dbSync ( );
dbPasteImage ( 1, 30, 0 ) ;
dbSync ( );
main_menu[0] = "New Game";
main_menu[1] = "Continue";
main_menu[2] = "Credits";
// SET VARIBLES FOR TITLE SCREEN
Cursor_Y_Pos = 0;
Cursor_X = X_Screen;
Cursor_Y = 220;
// SET VARIBLES FOR LOCATION IN TITLE SCREEN.
Title = true;
NewGame = false;
Continue = false;
Credits = false;
CharSet[0][0] = "A";
CharSet[0][1] = "B";
CharSet[0][2] = "C";
CharSet[0][3] = "D";
CharSet[0][4] = "E";
CharSet[0][5] = "F";
CharSet[0][6] = "G";
CharSet[0][7] = "H";
CharSet[0][8] = "I";
CharSet[0][9] = "J";
CharSet[0][10] = "K";
CharSet[0][11] = "L";
CharSet[0][12] = "M";
CharSet[0][13] = "N";
CharSet[0][14] = "O";
CharSet[0][15] = "P";
CharSet[0][16] = "Q";
CharSet[1][0] = "R";
CharSet[1][1] = "S";
CharSet[1][2] = "T";
CharSet[1][3] = "U";
CharSet[1][4] = "V";
CharSet[1][5] = "W";
CharSet[1][6] = "Y";
CharSet[1][7] = "X";
CharSet[1][8] = "Z";
CharSet[1][9] = "a";
CharSet[1][10] = "b";
CharSet[1][11] = "c";
CharSet[1][12] = "d";
CharSet[1][13] = "e";
CharSet[1][14] = "f";
CharSet[1][15] = "g";
CharSet[1][16] = "h";
CharSet[2][0] = "i";
CharSet[2][1] = "j";
CharSet[2][2] = "k";
CharSet[2][3] = "l";
CharSet[2][4] = "m";
CharSet[2][5] = "n";
CharSet[2][6] = "o";
CharSet[2][7] = "p";
CharSet[2][8] = "q";
CharSet[2][9] = "r";
CharSet[2][10] = "s";
CharSet[2][11] = "t";
CharSet[2][12] = "u";
CharSet[2][13] = "v";
CharSet[2][14] = "w";
CharSet[2][15] = "x";
CharSet[2][16] = "y";
CharSet[3][0] = "z";
CharSet[3][1] = "1";
CharSet[3][2] = "2";
CharSet[3][3] = "3";
CharSet[3][4] = "4";
CharSet[3][5] = "5";
CharSet[3][6] = "6";
CharSet[3][7] = "7";
CharSet[3][8] = "8";
CharSet[3][9] = "9";
CharSet[3][10] = "0";
CharSet[3][11] = "!";
CharSet[3][12] = "?";
CharSet[3][13] = "-";
CharSet[3][14] = " ";
CharSet[3][15] = "END";
// Load Sound FXs
// sound 1 is for intro music load on program start.
dbLoadSound ( "SoundFX\error.wav", 2 );
dbLoadSound ( "SoundFX\beep.wav", 3 );
dbSetSoundVolume ( 2, 100 );
dbSetSoundVolume ( 3, 100 );
}
/*
void KeyCheck ( )
{
if ( dbKeyState( 200 ) == 1 && Key[0].UpLimit == false)
{
Key[0].Up = true;
Key[0].UpLimit = true;
}
if ( dbKeyState( 208 ) == 1 && Key[0].DownLimit == false)
{
Key[0].Down = true;
Key[0].DownLimit = true;
}
if ( dbKeyState( 203 ) == 1 && Key[0].LeftLimit == false)
{
Key[0].Left = true;
Key[0].LeftLimit = true;
}
if ( dbKeyState( 205 ) == 1 && Key[0].RightLimit == false)
{
Key[0].Right = true;
Key[0].RightLimit = true;
}
if ( dbKeyState( 44 ) == 1 && Key[0].OkLimit == false)
{
Key[0].Ok = true;
Key[0].OkLimit = true;
}
if ( dbKeyState( 45 ) == 1 && Key[0].CancelLimit == false)
{
Key[0].Cancel = true;
Key[0].CancelLimit = true;
}
if ( dbKeyState( 30 ) == 1 && Key[0].MenuLimit == false)
{
Key[0].Menu = true;
Key[0].MenuLimit = true;
}
}
*/
void intro ( )
{
dbCLS ();
dbPasteImage ( 1, 30, 0 ) ;
dbText ( 0, 0,"Image should display:");
dbText ( 0, 20,dbStr( dbScreenFPS() ));
dbText ( 0, 60,dbStr( TempNameNum ));
if ( Title == true )
{
dbText ( Cursor_X - ( dbTextWidth ( main_menu[ Y_Temp ] )/2 + 15 ), Cursor_Y,">");
dbCenterText ( X_Screen, 220,main_menu[0]);
dbCenterText ( X_Screen, 250,main_menu[1]);
dbCenterText ( X_Screen, 280,main_menu[2]);
dbCenterText ( X_Screen, 380,dbStr( Key[0].DownLimit) );
dbText ( 0, 230,dbStr( Y_Temp ) );
dbText ( 0, 260,dbStr( Cursor_Y ) );
if ( Y_Temp == 3 )
{
Y_Temp = 0;
Cursor_Y = 220;
}
if ( Key[0].Up )
{
Cursor_Y = Cursor_Y - 30;
Y_Temp --;
}
if ( Y_Temp == -1)
{
Y_Temp = 2;
Cursor_Y = 280;
}
if ( Key[0].Down )
{
Cursor_Y = Cursor_Y + 30;
Y_Temp ++;
}
if ( Key[0].Ok )
{
if ( Y_Temp == 0 )
{
NewGame = true;
Title = false;
Key[0].Ok = false;
Cursor_X_Pos = 50;
Cursor_Y_Pos = 335;
X_Letter = 0;
Y_Letter = 0;
}
if ( Y_Temp == 1 )
{
Continue = true;
}
if ( Y_Temp == 2 )
{
Credits = true;
}
}
}
///////////////////////////////////////////////
if ( NewGame == true )
{
dbText ( 0, 230,dbStr( Y_Letter ) );
dbText ( 0, 260,dbStr( Cursor_X_Pos ) );
// bring up menu for name,
dbCenterText ( X_Screen,Y_Screen-1,(char*)Player[0].Name.c_str() );
dbCenterText ( X_Screen,335,"A B C D E F G H I J K L M N O P Q" );
dbCenterText ( X_Screen,365,"R S T U V W X Y Z a b c d e f g h" );
dbCenterText ( X_Screen,395,"i j k l m n o p q r s t u v w x y" );
dbCenterText ( X_Screen,425,"z 1 2 3 4 5 6 7 8 9 0 ! ? - END" );
dbCenterText ( Cursor_X_Pos,Cursor_Y_Pos,">" );
// MOVE CURSOR AROUND TEXT AREA.
if ( Key[0].Up )
{
Cursor_Y_Pos = Cursor_Y_Pos - 30;
Y_Letter --;
}
if ( Key[0].Down )
{
Cursor_Y_Pos = Cursor_Y_Pos + 30;
Y_Letter ++;
}
if ( Key[0].Right )
{
Cursor_X_Pos = Cursor_X_Pos + dbTextWidth ( "AA" );
X_Letter ++;
}
if ( Key[0].Left )
{
Cursor_X_Pos = Cursor_X_Pos - dbTextWidth ( "AA" );
X_Letter --;
}
// WRAP AROUND LETTERS
if ( Cursor_Y_Pos == 455 )
{
Cursor_Y_Pos = 335;
Y_Letter = 0;
}
if ( Cursor_Y_Pos == 305 )
{
Cursor_Y_Pos = 425;
Y_Letter = 3;
}
if ( Cursor_Y_Pos == 425 )
{
if ( Cursor_X_Pos == 562 )
{
Cursor_X_Pos = 50;
X_Letter = 0;
}
if ( Cursor_X_Pos == 18 )
{
Cursor_X_Pos = 530;
X_Letter = 15;
}
}else
{
if ( Cursor_X_Pos == 594 )
{
Cursor_X_Pos = 50;
X_Letter = 0;
}
if ( Cursor_X_Pos == 18 )
{
Cursor_X_Pos = 562;
X_Letter = 16;
}
}
if (Key[0].Ok)
{
if ( Y_Letter == 3 && X_Letter == 15 )
{
if ( dbLen ( (char*)Player[0].Name.c_str() ) == 0 )
{
//play error sound
dbPlaySound ( 2 );
}else
{
dbPlaySound ( 3 ); // play beep sound
Player[0].MaxHp = 16;
Player[0].MaxMp = 0;
Player[0].Hp = Player[0].MaxHp;
Player[0].Mp = Player[0].MaxMp;
Player[0].Exp = 0;
Player[0].Lv = 1;
Player[0].Atk = 7;
Player[0].Def = 7;
Player[0].Agi = 7;
Player[0].Str = 7;
Player[0].E_Weap = 0;
Player[0].E_Arm = 0;
Player[0].E_Shd = 0;
NewGame = false;
GameState = "Normal";
}
}else
{
if ( dbLen ( (char*)Player[0].Name.c_str() ) < 10 )
{
dbPlaySound ( 3 ); // play beep
Player[0].Name = Player[0].Name + CharSet[Y_Letter][X_Letter];
}
}
}
if ( Key[0].Cancel )
{
TempNameNum = dbLen ( (char*)Player[0].Name.c_str() );
Player[0].Name = dbLeft ( (char*)Player[0].Name.c_str(), TempNameNum - 1 );
}
}
//////////////////////////////////////////////////////////////
if ( Continue == true )
{
// no nothing.
}
if ( Credits == true )
{
// no nothing.
}
}
void EndRender( void )
{
Key[0].Up = false;
Key[0].Down = false;
Key[0].Left = false;
Key[0].Right = false;
Key[0].Ok = false;
Key[0].Cancel = false;
Key[0].Menu = false;
if ( dbKeyState( 208 ) == 0 && Key[0].DownLimit == true )
{
Key[0].DownLimit = false;
}
if ( dbKeyState( 200 ) == 0 && Key[0].UpLimit == true )
{
Key[0].UpLimit = false;
}
if ( dbKeyState( 203 ) == 0 && Key[0].LeftLimit == true )
{
Key[0].LeftLimit = false;
}
if ( dbKeyState( 205 ) == 0 && Key[0].RightLimit == true )
{
Key[0].RightLimit = false;
}
if ( dbKeyState( 44 ) == 0 && Key[0].OkLimit == true )
{
Key[0].OkLimit = false;
}
if ( dbKeyState( 45 ) == 0 && Key[0].CancelLimit == true )
{
Key[0].CancelLimit = false;
}
if ( dbKeyState( 30 ) == 0 && Key[0].MenuLimit == true )
{
Key[0].MenuLimit = false;
}
// update screen
dbSync ( );
}
void LoadMedia ( void )
{
}
and the header for that.
#pragma once
#include "resource.h"
void Setup ( void );
void LoadMedia ( void );
void intro ( void );
void KeyCheck ( void );
void EndRender( void );
bool Title;
bool NewGame;
bool Continue;
bool Credits;
int X_Screen;
int Y_Screen;
int Cursor_X;
int Cursor_Y;
int Cursor_X_Pos;
int Cursor_Y_Pos;
int Y_Temp;
int X_Temp;
int X_Letter;
int Y_Letter;
// GAME TYPES
/*
typedef struct tKey
{
bool Up; // Up Key Pressed
bool Down; // Down Key Pressed
bool Left; // Left Key Pressed
bool Right; // Right Key Pressed
bool Ok; // OK Key Pressed
bool Cancel; // Cancel Key Pressed
bool Menu; // Menu Key Pressed
bool UpLimit;
bool DownLimit;
bool LeftLimit;
bool RightLimit;
bool OkLimit;
bool CancelLimit;
bool MenuLimit;
} tKey;
*/
typedef struct tPlayer
{
std::string Name;
int MaxHp;
int MaxMp;
int Hp;
int Mp;
int Exp;
int Lv;
int Atk;
int Def;
int Agi;
int Str;
int E_Weap;
int E_Arm;
int E_Shd;
float X;
float Y;
float Z;
int Obj;
} tPlayer;
// GLOBAL GAME VARIABLES
//tKey Key[1];
char* main_menu[3];
tPlayer Player[1];
std::string CharSet[4][17];
char* TempName;
int TempNameNum;
std::string GameState;
enum tKey
{
Up, // Up Key Pressed
Down, // Down Key Pressed
Left, // Left Key Pressed
Right, // Right Key Pressed
Ok, // OK Key Pressed
Cancel, // Cancel Key Pressed
Menu, // Menu Key Pressed
UpLimit,
DownLimit,
LeftLimit,
RightLimit,
OkLimit,
CancelLimit,
MenuLimit,
};
enum tKey Key[1];
and i have the #include "DarkSDK.h" in my stdafx.h
and i am using vc++ .net 2003