Hi I'm Kevin and well I have encountered an unhandled exception while trying to compile and run a release build.
After a short while of commenting out code and testing I have isolated the problem to my Enemies.cpp
Unfourtinately I can't figure out what is wrong with it.
Here is the Error : "Unhandled exception at 0x000001f5 in Crazy Driver.exe: 0xC0000005: Access violation reading location 0x000001f5."
Here is the code for my Enemies.cpp
#include "DarkSDK.h"
#include "Enemies.h"
#include "Crazy Driver.h"
#include "Player.h"
bool g_bEnemiesSpawnedLeftB = false;
bool g_bEnemiesSpawnedMiddleB = false;
bool g_bEnemiesSpawnedRightB = false;
int g_iExplosionDelay = 0;
void Enemies::Spawn()
{
Enemies black;
black.Sprite = 10;
black.EnemyY = dbSpriteY( black.Sprite );
black.SpritePath = "Assets\\Black_anim.png";
int SpawnPosition = dbRND ( 3 );
int iEnemySpawn = dbRND ( 40 ) - g_iLevel;
if ( g_bPlayerHit == false )
{
if ( iEnemySpawn == 0 )
{
if (!dbImageExist(black.Sprite))
{
dbCreateAnimatedSprite ( black.Sprite , black.SpritePath , 3 , 3 , black.Sprite );
}
dbSetSpriteFrame ( black.Sprite, 7 );
dbSetSpritePriority ( black.Sprite, 2 );
switch( SpawnPosition )
{
case 1:
if ( black.EnemyY > 800 || g_bEnemiesSpawnedLeftB == false && g_bEnemiesSpawnedMiddleB == false && g_bEnemiesSpawnedRightB == false )
{
black.EnemyY = -200;
dbSprite( black.Sprite , 275 , -200 , black.Sprite );
g_bEnemiesSpawnedLeftB = true;
dbPlaySound ( 666 );
}
break;
case 2:
if ( black.EnemyY > 800 || g_bEnemiesSpawnedMiddleB == false && g_bEnemiesSpawnedLeftB == false && g_bEnemiesSpawnedRightB == false )
{
black.EnemyY = -200;
dbSprite( black.Sprite , 420 , -200 , black.Sprite );
g_bEnemiesSpawnedMiddleB = true;
dbPlaySound ( 666 );
}
break;
case 3:
if ( black.EnemyY > 800 || g_bEnemiesSpawnedRightB == false && g_bEnemiesSpawnedLeftB == false && g_bEnemiesSpawnedMiddleB == false )
{
black.EnemyY = -200;
dbSprite( black.Sprite , 550 , -200 , black.Sprite );
g_bEnemiesSpawnedRightB = true;
dbPlaySound ( 666 );
}
break;
}
}
}
}
void Enemies::Move ( void )
{
Enemies black;
black.Sprite = 10;
black.Speed = 8 + g_iLevel;
dbSprite ( black.Sprite , dbSpriteX ( black.Sprite ) , dbSpriteY ( black.Sprite ) + ( black.Speed ) , dbSpriteImage ( black.Sprite ) );
}
void enemyCheckCrash ( void )
{
Enemies black;
black.Sprite = 10;
if ( g_bPlayerHit == false )
{
if ( dbSpriteExist ( black.Sprite ) )
{
int iEnemyOffSetX = (dbSpriteWidth (black.Sprite) / 2) -40;
int iEnemyOffSetY = (dbSpriteHeight (black.Sprite) / 2) -40;
int iPlayerOffSetX = (dbSpriteWidth (1) / 2) -50;
int iPlayerOffSetY = (dbSpriteHeight (1) / 2) -30;
int iPlayerX = dbSpriteX ( 1 );
int iPlayerY = dbSpriteY ( 1 );
int iBulletX = dbSpriteX ( black.Sprite );
int iBulletY = dbSpriteY ( black.Sprite );
if ( ( iBulletX + iEnemyOffSetX > iPlayerX - iPlayerOffSetX && iBulletX - iEnemyOffSetX < iPlayerX + iPlayerOffSetX ) || ( iBulletX + iEnemyOffSetX > iPlayerX - iPlayerOffSetX && iBulletX - iEnemyOffSetX < iPlayerX - iPlayerOffSetX ) )
{
if ( ( iBulletY + iEnemyOffSetY > iPlayerY - iPlayerOffSetY && iBulletY - iEnemyOffSetY < iPlayerY + iPlayerOffSetY ) || ( iBulletY + iEnemyOffSetY > iPlayerY - iPlayerOffSetY && iBulletY + iEnemyOffSetY < iPlayerY + iPlayerOffSetY ) )
{
dbPlaySound ( 3 );
g_bPlayerHit = true;
}
}
}
}
}
Any help would be very much appreciated.
Kevin