A little while back i had some issues with how i was going to store my towers and enemies in my tower defence game, the kind posters on this forum gave me the advice to use a Vector. This is exactly what i need however i seem to get random crashes when ever i try to look inside the contents of the Vector. I have tried to fix within my game but that didnt work, so i made a test project which only has the vector related code within it.
The Error message that it gives is "The program '[1888] Vector Test.exe: Native' has exited with code -1073740777 (0xc0000417)"
#include "DarkGDK.h"
#include <vector>
using namespace std;
class cEnemy
{
public:
//=== CLASS CONSTRUCTOR ===
cEnemy(char* Name_c, int Xpos_c, int Zpos_c, int Life_c, int Damage_c);
//=== CLASS VARIABLES ===
char* Name;
int Xpos;
int Zpos;
int Life;
int Damage;
};
cEnemy::cEnemy(char* Name_c, int Xpos_c, int Zpos_c, int Life_c, int Damage_c)
{
Name = Name_c;
Xpos = Xpos_c;
Zpos = Zpos_c;
Life = Life_c;
Damage= Damage_c;
}
int i;
vector <cEnemy> Enemies;
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
Enemies.push_back( cEnemy( "enemy", 0, 31, 100, 50) );
while ( LoopGDK ( ) )
{
if (dbKeyState (17) == 1)
{
Enemies.push_back( cEnemy( "enemy", 0, 31, 100, 50) );
i++;
}
if (dbKeyState (18) == 1){
dbSetCursor (20,20);
dbPrint ((double)Enemies[i].Life );
}
if (dbKeyState (19) ==1)i++;
if (dbKeyState (20)==1)i--;
dbSetCursor (40,40);
dbPrint ((double)i);
dbSync ( );
}
return;
}
Anything u notice i most likely havent so please feel free to point it out (including bad habits,ineffient code practices and potential errors
thanks, CLICK
People dont kill People, Lag Kills People