Use offset sprite on the cannon to set the base of the barrel as the point of rotation (pivot).
sync on : sync rate 60
` Create the cannon
cls 0
box 15,0,17,32
get image 1, 0, 0, 32, 32
` Create the tank
cls 0
box 0, 8, 32, 24
get image 2, 0, 0, 32, 32
` CANNON
sprite 1, 100+16, 100+16, 1
offset sprite 1, 16, 32 ` Offset the pivot point to be at the end of the barrel.
` TANK
sprite 2, 100, 100, 2
` Angle for rotation
a# = 0.0
` Main Loop
do
rotate sprite 1, a#
` Change the angle of the cannon.
inc a#, 0.5
a# = wrapvalue(a#)
sync
loop