Need help with code

Hey guys,

Im trying to make an RPG type game for a school project and I need help with a bit of code. Basically, im trying to make an arrow shoot from my archers bow(located in the middle of the screen) to the location of my cursor. Here’s my code:

In the MouseDown event:

dim angle as double

MpositionX = system.mousex-(canvas1.width/2)
MpositionY = (canvas1.height/2)-system.mousey

angle = atan2(MpositionY , MpositionX)*180/pi


In my timer:


the arrow just goes in a completely random direction.
does anyone know why??


angle = atan2(MpositionY , MpositionX)*180/pi

that is converting to DEGREES, as ATAN2 returns RADIANS
but COS and SIN expect RADIANS , yet you are giving them DEGREES

so try

angle = atan2(MpositionY , MpositionX)

Thank you so much!!! I don’t know how I didn’t think of removing that 180/pi.