realized it after thread was sent for approval couldn't modify anything .. will post source here
CPP Files:
Main
#include <DarkGDK.h>
#include <Main.h>
#include <Graphic files.h>
#include <Backdrop.h>
#include <Player.h>
#include <Input.h>
enum eMode {eGameTitle,
eGameMenu,
eGamePlay,
};
eMode g_eGameMode = eGameMenu;
void DarkGDK ( void )
{
while ( LoopGDK() )
{
game();
dbSync();
}
}
void game ( void )
{
switch ( g_eGameMode )
{
case eGameTitle: gameTitle(); break;
case eGameMenu: gameMenu(); break;
case eGamePlay: gamePlay(); break;
}
}
void gameTitle ( void )
{
dbSetDisplayMode ( 1024 , 768 , 32 );
dbSyncOn();
dbSyncRate(60);
dbSetWindowTitle ( "Test" );
dbSetTextFont ( "courier" );
dbSetTextSize ( 50 );
g_eGameMode = eGameMenu;
}
void gameMenu ( void )
{
dbSetDisplayMode ( 1024 , 768 , 32 );
dbCLS();
dbCenterText ( 512,340, "Test game");
dbCenterText (512,360, "Spacebar to start");
if(dbKeyState(57) ) {
g_eGameMode = eGamePlay;
}
}
void gamePlay ( void )
{
dbSetDisplayMode ( 1024 , 768 , 32 );
dbCLS();
dbCenterText ( 512,340, "Game play enabled");
BackdropUpdate();
BackdropSetup();
playerSetup();
playerUpdate();
}
Player
#include "DarkGDK.h"
#include "Player.h"
#include "Input.h"
int iPlayerX = 423;
int iPlayerY = 668;
int iPlayerSpeed = 5;
int iPlayerFrame = 7;
int iFrameAnimateDelay = 0;
bool bPlayerIsFiring = false;
int iPlayerBulletY = 0;
int g_PlayerDieFrame = 1;
int g_PlayerExplosionDelay = 0;
void playerSetup ( void )
{
dbCreateAnimatedSprite ( 1, "Assets\\ship_anim.png ", 3 ,3 , 1 );
dbSprite ( 1 , iPlayerX , iPlayerY , 1 );
dbSetSpriteFrame ( 1, iPlayerFrame );
dbSetSpritePriority ( 1,2 );
}
void playerUpdate ( void );
void playerAnimate ( void );
void playerReset ( void );
bool playerLevelStart ( void );
bool playerLevelStart2 ( void );
void playerUpdateFire ( void );
bool playerDie ( void ) ;
void playerUpdate ( void )
{
if (checkLeft())
{
iPlayerX -= iPlayerSpeed;
if ( iPlayerX < 0 )
iPlayerX = 0;
}
else if ( checkRight() )
{
iPlayerX += iPlayerSpeed;
if ( iPlayerX > 1024 - 128 )
iPlayerX = 1024 - 128;
}
dbSprite ( 1 , iPlayerX , iPLayerY , 1);
}
Backdrop
#include "DarkGDK.h"
#include "Backdrop.h"
float fBackDropBottomScrollY = 0;
float g_fBackdropSpeed = 10.0f;
void BackdropSetup( void )
{
dbLoadImage ( "Assets\\test-backdrop.png" , 50);
}
void BackdropUpdate( void )
{
fBackDropBottomScrollY += 0.35f*g_fBackdropSpeed;
if ( fBackDropBottomScrollY >= 768.0f )
fBackDropBottomScrollY = 1.0f ;
dbSprite ( 50 , 0 , (int)fBackDropBottomScrollY , 50 );
dbSprite ( 51 , 0 , (int)fBackDropBottomScrollY-768 , 50 );
}
Input
#include "DarkGDK.h"
#include "Input.h"
bool checkLeft ( void )
{
if ( dbKeyState ( 107 ) )
return true;
return false;
}
bool checkRight ( void )
{
if ( dbKeyState ( 109 ) )
return true;
return false;
}
HEADER Files:
Main
#pragma once
void gameTitle ( void );
void game ( void );
void gameMenu ( void );
void gamePlay ( void );
Player
#pragma once
void playerSetup ( void );
void playerUpdate ( void );
extern int iPlayerX;
extern int iPlayerY;
extern int iPlayerSpeed;
extern int iPlayerFrame;
extern int iFrameAnimateDelay;
extern bool bPlayerIsFiring;
extern int iPlayerBulletY;
extern bool g_bPlayerHit;
extern int g_iPlayerDieFrame;
Backdrop
#pragma once
void BackdropSetup( void );
void BackdropUpdate( void );
extern float g_fBackdropSpeed;
Input
#pragma once
bool checkLeft ( void );
bool checkRight ( void );
And if anyone wants to download the FULL source + sprite and backdrop image go to http://filebeam.com/76847424aacf60deafa3074c1eea5eaf .