Thank you was away on vacation, but now I have another problem loading sound if anyone can help me.Can Dark GDK load .mp3? I've tried but didn't hear anything so I converted to .wav and tried again but no luck :0. Here is the source code FULL again :
Mr. Hankey.cpp
#include "DarkGDK.h"
#include "Mr Hankey.h"
#include "Backdrop.h"
#include "Player.h"
#include "Input.h"
#include "Sound.h"
enum eMode { eGameSetup,
eGameReset,
eGameTitle,
eGameWaitForFire,
eGameLevel,
eGameLevelWait,
eGameLevelWait2,
eGamePlay,
eGameDie,
eGameWin,
eGameOver };
eMode g_eGameMode = eGameSetup;
int g_iLevel = 1;
int dbMouseMoveX ( void );
int dbMouseMoveY ( void );
void DarkGDK (void)
{
while ( LoopGDK() )
{
game();
dbSync();
}
}
void game ( void )
{
BackdropUpdate();
switch ( g_eGameMode )
{
case eGameSetup: gameSetup(); break;
case eGameTitle: gameTitle(); break;
case eGamePlay: gamePlay(); break;
case eGameWin: gameWin(); break;
case eGameOver: gameOver(); break;
case eGameLevel: gameLevel(); break;
case eGameWaitForFire: gameWaitForFire();break;
}
}
void gameSetup ( void )
{
BackdropSetup();
dbSetDisplayMode ( 800 , 600 , 32 );
dbSyncOn();
dbSyncRate(60);
dbSetWindowTitle ( "Mr. Hankey" );
dbSetTextFont ( "courier" );
dbSetTextSize ( 24 );
g_eGameMode = eGameTitle;
}
void gameTitle( void )
{
dbCLS();
dbCenterText ( 512, 340, "Mr. Hankey" );
dbCenterText ( 512, 360, "Fart to start" );
dbSetTextFont ( "asfadgsc" );
g_iLevel = 1;
g_eGameMode = eGameWaitForFire;
dbSetSoundSpeed ( 1 , 11 );
dbPlaySound ( 1 );
}
void gamePlay ( void )
{
if ( dbRND(1)==0 )
g_eGameMode = eGameWin;
else
g_eGameMode = eGameDie;
}
void gameWin( void )
{
dbCLS();
dbCenterText ( 512, 340, "Nice Poo!");
dbCenterText ( 512, 360, "Fart, on!");
g_iLevel++;
g_eGameMode = eGameReset;
}
void gameOver ( void )
{
dbCLS();
dbCenterText ( 512, 340, "You ate the poo...");
dbCenterText ( 512, 360, "P P P");
if (dbSpaceKey() )
{
//switch to display the level screen
while ( dbSpaceKey() ) {}
g_eGameMode = eGameTitle;
}
}
void gameWaitForFire ( void )
{
if ( checkFire() )
{
g_eGameMode = eGameLevel;
dbPlaySound ( 1 );
}
}
void gameLevel ( void )
{
BackdropSetup();
BackdropUpdate();
float y = dbMouseMoveY( );
dbPlaySound ( 1 );
}
Mr. Hankey.h
#pragma once
void game ( void );
void gameSetup ( void );
void gameReset ( void );
void gameTitle ( void );
void gameWaitForFire ( void );
void gameLevel ( void );
void gameLevelWait ( void );
void gameLevelWait2 ( void );
void gamePlay ( void );
void gameWin ( void );
void gameDie ( void );
void gameOver ( void );
void soundSetup ( void );
extern int g_iLevel;
extern int g_iLevelStartTime;
Backdrop.h
#pragma once
void BackdropSetup( void );
void BackdropUpdate( void );
extern float g_fBackdropSpeed;
Backdrop.cpp
#include "DarkGDK.h"
#include "Backdrop.h"
float fBackDropBottomScrollY = 0;
float g_fBackdropSpeed = 5.0f;
void BackdropSetup( void )
{
dbLoadImage ( "Assets\1234.png" , 50);
dbPlaySound ( 1 );
}
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 );
}
Player.h
#pragma once
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;
void playerUpdate ( void );
void playerAnimate ( void );
void playerReset ( void );
void playerLevelStart ( void );
void playerLevelStart2 ( void );
void playerUpdateFire ( void );
void playerDie ( void );
Player.cpp
#include "DarkGDK.h"
#include "Player.h"
int iPlayerX = 448;
int iPlayerY = 650;
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\Untitled-1.jpg ", 3 ,3 , 1 );
dbSprite ( 1 , iPlayerX , iPlayerY , 1 );
dbSetSpriteFrame ( 1, iPlayerFrame );
}
void playerUpdate ( void );
void playerAnimate ( void );
void playerReset ( void );
void playerLevelStart ( void );
void playerLevelStart2 ( void );
void playerUpdateFire ( void );
void playerDie ( void );
Input.cpp
#include "DarkGDK.h"
#include "Input.h"
bool checkFire ( void )
{
if ( dbKeyState ( 57 ) || dbKeyState ( 29 ) || dbKeyState ( 157 ) )
return true;
return false;
}
bool checkLeft ( void )
{
if ( dbKeyState ( 57 ) || dbKeyState ( 29 ) || dbKeyState ( 157 ) )
return true;
return false;
}
bool checkRight ( void )
{
if ( dbKeyState ( 57 ) || dbKeyState ( 29 ) || dbKeyState ( 157 ) )
return true;
return false;
}
Input.h
#pragma once
bool checkFire ( void );
bool checkLeft ( void );
bool checkRight ( void );
Sound.h
#pragma once
void soundSetup ( void );
Sound.cpp
#include "DarkGDK.h"
#include "Sound.h"
void soundSetup ( void )
{
dbLoadSound ( "Assets\best.wav" , 1 );
dbPlaySound ( 1 );
}
Hope someone can help me, thanks.
Edit: Problem is I don't hear anything, it gives me no error though and can run the program.