This is basically an example to newcomers of how to use Sin and Cos. I know a thread about this has already been made, but this is slightly different. Notice that with this code you can always estimate what's infront depending on the angle. I used sin and cos in this to move the tank, to plot the points for the tanks main bit, and the next position for the turret. It also shows you hwo to use the atanfull command to get the angle between two coordinates. This can all be used in 3D too
`Setup
sync on : sync rate 60
set display mode 1024,768,16
set window on : maximize window
`Position of tank
x=screen width()/2
y=screen height()/2
`Size of tank and turret
size=100
tursize=100
`Speed of tank
speed=2
`Main Loop
do
cls
`Get mouse coordinates
mx=mousex()
my=mousey()
`get angle between mouse and tank
ang=atanfull(mx-x,my-y)
`Calculate next positions for turret
flx=x+sin(ang)*tursize
fly=y+cos(ang)*tursize
`Calculate coords for corners of tank
x1=x-sin(wrapvalue(ang+45))*(size/2)
y1=y-cos(wrapvalue(ang+45))*(size/2)
x2=x+sin(wrapvalue(ang+135))*(size/2)
y2=y+cos(wrapvalue(ang+135))*(size/2)
x3=x-sin(wrapvalue(ang+225))*(size/2)
y3=y-cos(wrapvalue(ang+225))*(size/2)
x4=x+sin(wrapvalue(ang+315))*(size/2)
y4=y+cos(wrapvalue(ang+315))*(size/2)
`Calculate new positions for tank
x=x+sin(ang)*speed
y=y+cos(ang)*speed
`Draw tank
line x1,y1,x2,y2
line x4,y4,x3,y3
line x4,y4,x1,y1
line x3,y3,x2,y2
line x,y,flx,fly
`End Loop
sync
loop