I've made the changes you mentioned, assuming that this is fine:
char* str;
//Converts score into text and displays it
str = "Kills:";
dbText(65,65,str);
str = dbStr(player.Kills);
dbText(120,65,str);
str = "RoundsFired:";
dbText(160,65,str);
str = dbStr(player.RoundsFired);
dbText(270,65,str);
str = "HP:";
dbText(320,65,str);
str = dbStr(player.HP);
dbText(360,65,str);
delete[] str;
the debug build works fine, but when I run the release version (through the VC++ debugger, it crashes straight away otherwise =s) i get this error:
Quote: "Unhandled exception at 0x0000012e in RedDotArena.exe: 0xC0000005: Access violation"
which I'm guessing it's trying to tell me an array is out of bounds (or that's the most likely problem).
I think i've narrowed it down to this bit of code:
if(dbMouseClick())
{
player.RoundsFired++;
//Creates a random seed.
srand(dbTimer());
dbPlaySprite(player.Sprite,1,2,50);
//Increment bullet count
bCount++;
//If bullet count is out of bounds, reset bullet count.
if(bCount>=5000)
{
bCount=0;
for(int j=0; j<=5000; j++)
{
if(bullet[j].Sprite!=0)
{
dbDeleteSprite(bullet[j].Sprite);
}
}
}
//Gets bullet spawn points
int SpawnX = dbSpriteX(player.Sprite);
int SpawnY = dbSpriteY(player.Sprite);
dbSprite(bCount+200,SpawnX,SpawnY,10);
bullet[bCount].Sprite = bCount+200;
bullet[bCount].Angle = dbSpriteAngle(player.Sprite)+(rand()%3-3);
//Sets a random bullet lifespan
srand(dbTimer());
bullet[bCount].DistNew = (rand()%5-4);
bullet[bCount].Velocity = 10;
bullet[bCount].Player = 1;
//Positions the bullet infront of the gun barrel
dbRotateSprite(bullet[bCount].Sprite, bullet[bCount].Angle+90);
dbMoveSprite(bullet[bCount].Sprite, 30);
dbRotateSprite(bullet[bCount].Sprite, bullet[bCount].Angle);
dbMoveSprite(bullet[bCount].Sprite, 60);
}
AND
for(int j=0; j<=5000; j++)
{
if(bullet[j].Sprite!=0)
{
dbDeleteSprite(bullet[j].Sprite);
}
}
as the error only happens (when debugging at least) when I click the mouse and that's the only part of my program which does anything when the user clicks the mouse, however it might be another part of the program as it crashes right away when I run it outside of the debugger. It's probably something to do with my creation of bullets as when I comment out all the functions to do with deleting and creating bullets it works fine while debugging, but still crashes straight away when I run it out of the debugger.
note: During all this I was making a release build, the debug build works 100%