Quote: "Yeah I know!!!!!! I dont know how!"
Just like what was said above use "atanful" to get the angle and use "sin" and "cos" to get the amounts you need to add/subtract from the center x and y coordinates.
I made this code snip for you... it should be everything you want with plenty of rem statements to tell you whats going on.
This should work in both Classic and Pro:
sync rate 0
sync on
randomize timer()
backdrop on
` Define Center of screen, Bullet x and y Variables,
` and Bullet Radius (which is the amount of pixels
` to skip each time the bullet moves)
StartX=screen width()/2
StartY=screen height()/2
BulletX=StartX
BulletY=StartY
BulletRadius=10
` Create the Bullet and Bullet Sprite
box 0,0,2,2
get image 1,0,0,2,2,1
sprite 50,BulletX,BulletY,1
offset sprite 50,1,1
` Create Enemy Image
ink rgb(172,255,122),0
box 0,0,30,30
for t=1 to 100
ink rgb(rnd(255),rnd(255),rnd(255)),0
dot rnd(30),rnd(30)
next t
get image 2,0,0,30,30,1
` Make 15 Enemy Sprites
for t=1 to 15
sprite t,rnd(600)+40,rnd(460)+20,2
next t
do
` Get the amount of pixels between the center of the
` screen to the current mouse coordinates
x=mousex()-StartX
y=mousey()-StartY
` Get the angle needed to travel from the center to
` the mouse coordinates
angle=wrapvalue(ATANFULL(y,x))
` Get the amount of x and y to add/subtract to move
` 20 pixels out using the angle (this is used for
` the next set of lines)
radius=20
c=cos(angle)*radius
s=sin(angle)*radius
` Make a line to show the current angle and show the
` bullet sprite (increase the radius variable above
` to increase the size of the line created)
ink rgb(rnd(255),rnd(255),rnd(255)),0
line StartX,StartY,StartX+c,StartY+s
sprite 50,BulletX,BulletY,1
` Show Mouse Information and Angle
ink rgb(255,255,255),0
text 0,0,"MouseX = "+str$(mousex())
text 0,20,"MouseY = "+str$(mousey())
text 0,40,"Angle = "+str$(angle)
if mouseclick()
do
` This timer is to set the bullet speed
` Lower the 100 and the bullet moves faster
if timer()>pace+100
pace=timer()
` Find the amount to add/subtract from the x and y
` from the current bullet x and y coordinates
c=cos(Angle)*BulletRadius
s=sin(Angle)*BulletRadius
BulletX=c+BulletX
BulletY=s+BulletY
` Show sprite and check if it collides with
` another sprite
sprite 50,BulletX,BulletY,1
Hit=sprite collision(50,0)
` Show Bullet Information
ink rgb(255,255,255),0
text 0,0,"BulletX = "+str$(BulletX)
text 0,20,"BulletY = "+str$(BulletY)
if Hit>0 then text 0,40,"Hit Sprite #"+str$(Hit)
` Check if the bullet goes beyond the screen
if BulletX<0 or BulletX>screen width() then exit
if BulletY<0 or BulletY>screen height() then exit
sync
endif
loop
` Reset Bullet x and y coordinates to center
BulletX=StartX
BulletY=StartY
endif
sync
loop