Using DarkGDK
So I've created a function to find an angle between two points, that works since my sprite points in the correct direction(my mouse). My problem is getting sprites to move in the direction they are facing(a bullet).
I found some material on this forum and it works, to a degree. I've modified it for my own purposes.
functions.cpp
double lengthdirX(double dist, double dir){
return dist*cos(dir*(PI/180));
}
double lengthdirY(double dist,double dir){
return dist*sin(dir*(PI/180));
}
player.cpp
bullets[i].x+=lengthdirX(spd,dir);bullets[i].y+=lengthdirY(spd,dir);dbSprite(i,bullets[i].x,bullets[i].y,BULLET);
As I said, it works to a degree. The bullet fires in the
general direction of the mouse, but seems to round the angle. I've included a picture of what I am saying, the black circle is where my mouse was at the time of firing and the red dot is the bullet. The player's direction and the bullet's direction are the same upon firing and both are doubles.