So I have been coding the starting part of a game I want to make but I can't get it to work the way I want, and I have NO idea why it isn't. I've looked it over and over and it should work but isn't. I'm thinking it is some sly part of the program that a novice wouldn't know. Here is the code.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( ); // turn on sync rate and set maximum rate to 60 fps
dbSyncRate ( 60 );
if ( dbCheckDisplayMode ( 1366, 768, 32 ) ) // checks if the display mode is compatible with device
dbSetDisplayMode ( 1366, 768, 32 ); // changes to display mode if compatible
dbSetImageColorKey ( 255, 0, 255 ); // turns bright pink to transparent
dbMaximizeWindow ( ); // this maximizes the window
dbSetWindowOff ( );
dbDisableEscapeKey ( ); // disables escape key
dbRandomize ( dbTimer ( ) ); // Gives better random seed value
int Screen = 1;
bool Menu = true;
bool MenuLoaded = false;
bool Game = false;
bool LevelOneLoaded = false;
bool SpaceKeyBool = false;
bool SpacePressed = false;
bool SpaceClick = false;
dbDrawSpritesFirst ( );
// our main loop
while ( LoopGDK ( ) )
{
if ( dbSpaceKey ( ) && SpacePressed == false )
{
SpaceKeyBool = true;
SpacePressed = true;
}
else SpaceKeyBool = false;
if ( SpaceKeyBool == false && SpacePressed == true )
{
SpaceClick = true;
SpacePressed = false;
}
if ( Menu == true && Screen == 1 )
{
if ( MenuLoaded == false )
{
dbLoadImage ( "Media/Menu/MainMenu.bmp", 1 );
dbLoadImage ( "Media/Menu/MainMenuPlayGameButton.bmp", 2 );
dbSprite( 1, 0, 0, 1 );
dbSprite ( 2, 125, 250, 2 );
dbSetSpritePriority ( 1, 1 );
dbSetSpritePriority ( 2, 2 );
SpaceClick = false;
MenuLoaded = true; // This is where we will add the coding for the menu
}
if ( MenuLoaded == true )
{
bool PlayGameXY;
if ( (dbMouseY ( ) >= dbSpriteY ( 2 )) && ( dbMouseY ( ) <= ( dbSpriteY ( 2 ) + 73 ) ) && ( dbMouseX ( ) >= dbSpriteX ( 2 ) ) && ( dbMouseX ( ) <= ( dbSpriteX ( 2 ) + 459 ) ) )
PlayGameXY = true;
else PlayGameXY = false;
dbText ( 100, 100, "Menu is loaded. Press 'Play Game' to play." );
/*if ( PlayGameXY == true )
dbChangeMouse ( 4 ); */ // changes mouse to finger
if ( dbMouseClick ( ) && PlayGameXY == true )
{
dbHideSprite ( 1 );
dbHideSprite ( 2 );
Game = true;
Menu = false; // exits and deletes the menu items
Screen = 2;
}
}
if ( Game == true && Screen == 2 ) // Senses whether or not the game is going on unpaused
{
if ( LevelOneLoaded == false )
{
dbLoadImage ( "Media/LevelOne/LevelOneMapOne.bmp", 3 ); // This will be the starting map
dbSprite ( 3, 0, 0, 3 );
LevelOneLoaded = true;
}
if ( LevelOneLoaded == true )
{
dbText ( 10, 10, "Level One is now loaded." );
if ( dbLeftKey ( ) )
{
Screen = 0;
dbHideSprite ( 3 );
}
}
}
if ( Game == true && Screen == 0 ) // senses whether or not the game is paused
{
bool PlayGameXY;
if ( (dbMouseY ( ) >= dbSpriteY ( 2 )) && ( dbMouseY ( ) <= ( dbSpriteY ( 2 ) + 73 ) ) && ( dbMouseX ( ) >= dbSpriteX ( 2 ) ) && ( dbMouseX ( ) <= ( dbSpriteX ( 2 ) + 459 ) ) )
PlayGameXY = true;
else PlayGameXY = false;
dbShowSprite ( 2 );
dbSetSpritePriority ( 2, 2 );
dbSetSpritePriority ( 3, 1 );
if ( dbMouseClick ( ) && PlayGameXY == true )
{
dbHideSprite ( 2 );
Screen = 2;
}
}
}
// update the screen
dbSync ( );
if ( dbEscapeKey ( ) ) // checks to see if Escape Key is pushed
break; // shuts process down if Escape Key is pushed
}
// return back to windows
return;
}
When I click "Play Game" it loads the next map but doesn't show the text. When I leave the map out, the text briefly flashes but disappears. After that point the coding doesn't work, except for the dbEscapeKey ( ) function. Is there something I am missing??
-BTERangerEllis-