So first, I have an abstract base class named "Ship" that contains this:
Code: Select all
std::vector<Bullet*> bullets;
Code: Select all
void Player::shoot()
{
if(wantShoot == true)
{
if(bulletCount.is_started()==false || bulletCount.get_ticks()>200)
{
MedBullet bullet(x+(images[EplayerShip]->w/2)-5,y-7);
bullets.push_back(&bullet);
if(bulletCount.is_started() == false)
{
bulletCount.start();
}else{
bulletCount.stop();
bulletCount.start();
}
}
}
}
Code: Select all
for(int i = 0; i < (int)bullets.size(); i++)
{
bullets[i]->show(); //It crashes here
Code: Select all
void show()
{
apply_surface(x,y,images[EmedBullet],screen,NULL);
}
//apply surface
void apply_surface(int x, int y, SDL_Surface * source, SDL_Surface * destination, SDL_Rect* clips)
{
SDL_Rect offset;
offset.x=x;
offset.y=y;
if(source != NULL)
{
SDL_BlitSurface(source, clips, destination, &offset);
}
}