spawning a bullet
for (//loop through bullets)
{
if ( bullets[i].active == false )
{
bullets[i].active = true;
bullets[i].x = (player.x + player.rad - bullets[i].rad); //Middle of player bubble
bullets[i].y = (player.y + player.rad - bullets[i].rad); //
player.ammo--;
break;
}
}
checking if it's of the screen
for ( //loop through all bullets)
{
if (//bullets[i].x or bullets[i].y out of screen)
{
bullets[i].active = false;
}
if (bullets[i].active == true)
{
bullets[i].move();
bullets[i].draw( m_Screen );
}
}
After reading a tutorials on this site which involved working with the mouse i used that so it draws a line between the middle of my player bubble to the mouse x and y coordinates (blue line in screenshot).

Currently the bullets are just travelling downwards to face the upcomping horde of bubbles, but now i want to be able to shoot the bullets towards the end of the line and keep them moving towards that point even if the mouse has moved. I tried to do so with slope values and such but i can't get my head around the maths that is needed here.
If i click, it spawns a bullet at my player's x and y coordinates. I have added a variable which can hold the direction for every bullet object but i don't know how to get that direction and how to keep a bubble moving towards the point that i defined with the cursor when i clicked.













