You can calculate the angle of the click and the mouse by using:
[source lang="cpp"]angle = atan2f(clickedPosition.y - currentPos.y, clickedPosition.x - currentPos.x);[/source]
Then use the angle to calculate a "final" position, given a maximum distance that a bullet shall move:
[source lang="cpp"]finalX = currentPos.fX + (cos(angle) * maximumMovement);nextY = currentPos.fY + (sin(angle) * maximumMovement);[/source]
And finally use the bresenham algorithm to find all the pixels the buttlet would move by:
[source lang="cpp"]void bresenham(unsigned x0, unsigned y0, unsigned x1, unsigned y1){ int dx = absolute(x1-x0); int dy = absolute(y1-y0); int sx, sy; if (x0 < x1){ sx = 1; } else{ sx = -1; } if (y0 < y1){ sy = 1; } else{ sy = -1; } int err = dx-dy; while (!(x0 == x1 && y0 == y1)){ int errTimesTwo = 2 * err; if (errTimesTwo > -dy){ err -= dy; x0 = x0 + sx; } if (errTimesTwo < dx){ err += dx; y0 += sy; } }}[/source]
Of course you would need some adjusts if you want the bullets to be dodgeable/renderable projectiles.
The advantages of this method is that it is really easy to find the bullet path and check for collisions if you need it.
Hope this helps