Hello gamedev.
I'm currently programming a simple 2d space shooter in sfml 2.0 .
Does anyone have any idea how will I make the missiles move at the same speed at any direction? (The problem is partially solved for vertical directions only).
Here is my code:
void World::updateMissiles(float refreshRate){
std::list<Missile*>::iterator it = missiles.begin();
while(it != missiles.end()){
Missile* missile = *it;
sf::Sprite& sprite = missile->getSprite();
if(collide(missile)){
it=missiles.erase(it);
delete missile;
}
else{
if(missile->getType() == Missile::Player){
// Missile angle of player is only vertical
sprite.move(0,-missile->getVelY()*refreshRate);
}
else{
// This part needs to change from vertical to angles of 45,90,135 degrees
//sprite.move(0,missile->getVelY()*refreshRate);
}
it++;
}
}
}