samedi 26 avril 2014

I'm trying to shoot with vectors


Vote count:

0




I am currently writing a game in c++ with direct X and currently a vector to store draw all my sprites. I cant get bullets to work in the vector the bullet shoots but only one comes out when there should be 50



//this vector also contains all other sprites i have like my player and my score and other sprites
///Draw is a class
vector<Draw*> chap;
vector<Draw*>::iterator it;
Draw *bullet = NULL;

for (int i = 0; i < gt; i++)
{
bullet = new Draw[gt];
//this sets the x position and y position and other properties
bullet[i].setDraw(blet,0,0,.1,.1,0,64,64,1,0,1,color,0,0,90,0,0,false);
chap.push_back(&bullet[i]);
}
for (int i = 0; i < bell; i++)
{
for (it = chap.begin(); it != chap.end(); it++)
{
(*it)->testShoot(&bullet[i], ME);
ME->playerMove();
monster1->move();
}
}


/// what im using
void Draw::testShoot(Draw *sprite, Draw *sprite1)
{
if ((int)timeGetTime() < timer + 100)return;
timer = timeGetTime();

for (int i = 0; i < 50; i++)
{

if (Key_Down(DIK_SPACE))
{

if (!sprite[i].alive)
{
sprite[i].x = sprite1->x + sprite1->width / 4;
sprite[i].y = sprite1->y + sprite1->height / 4;
sprite[i].velx = 1;
sprite[i].vely = 0;
sprite[i].alive = true;
break;
}
}
}
}


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire