Heres some code I just created quickly to help you
sync on
sync rate 0
sync
hide mouse
EnemyX = 320
EnemyY = 240
BulletSpeed# = 0.4
cls rgb(255,255,255)
get image 1,0,0,32,32
cls rgb(0,255,0)
get image 2,0,0,8,8
cls rgb(0,0,255)
get image 3,0,0,32,32
sprite 1,mousex(),mousey(),1
sprite 2,EnemyX,EnemyY,2
sprite 3,EnemyX,EnemyY,3
for Index = 1 to 3
offset sprite Index,(sprite width(Index) / 2),(sprite height(Index) / 2)
set sprite Index,0,1
next Index
hide sprite 2
cls 0
do
cls
OldTime = NewTime
NewTime = timer()
FrameTime = NewTime - OldTime
if mouseclick() = 1 and Fired = 0
Fired = 1
show sprite 2
MoveX# = mousex() - EnemyX
MoveY# = mousey() - EnemyY
Angle# = atanfull(mousex() - EnemyX,mousey() - EnemyY) - 90.0
MoveX# = BulletSpeed# * cos(Angle#)
MoveY# = (BulletSpeed# * -1) * sin(Angle#)
endif
if Fired = 1
BulletX# = BulletX# + (MoveX# * FrameTime)
BulletY# = BulletY# + (MoveY# * FrameTime)
sprite 2,EnemyX + int(BulletX#),EnemyY + int(BulletY#),2
if sprite collision(1,2) = 1 or sprite x(2) < 0 or sprite x(2) > 640 or sprite y(2) < 0 or sprite y(2) > 480
Fired = 0
hide sprite 2
BulletX# = 0
BulletY# = 0
endif
endif
sprite 1,mousex(),mousey(),1
sprite 3,EnemyX,EnemyY,3
text 0,0,"Move with mouse, press left mouse button to make enemy fire"
text 0,20,"FPS " + str$(screen fps())
sync
loop
Basically whats going on is that the angle between the player and enemy is found. Then the angle is wrapped into the proper quadrant.
By multiplying the BulletSpeed (measured in pixels per second) with cos(Angle) you get the horizontal component or the BulletSpeed, and by multiplying the BulletSpeed with sin(angle) you get the verticle component.
These components are then added to the Bullets coordinates to move the bullet, however the components are first multiplyed by the frame time - this is for timer based movement which means the bullet will move the same distance no matter the frame rate.