Sorry I didn't give more explanation last night, I must have been getting tired. Here is the code again, this time with a lot of comments:
sync rate 60
sync on
`these two variables act as switches, on or off, one or zero
`started = 1 means that line drawing has started
`started = 0 means that line drawing is not active
`mousehold = 1 means the left mouse button is being held down
`mousehold = 0 means the left mouse button is not being held down
started as boolean
mousehold as boolean
started=0
mousehold=0
`these variables save the old x and y positions for the line function
`they were floats, but the line function does not require floats
`so they have been changed to intergers
oldx=0
oldy=0
`the main loop
do
if mouseclick()=1
`the left mouse button has been pressed
if not mousehold
`the left mouse button was not being held down
`but since it has now been pressed we will mark it as
`now being held down
mousehold=1
if started
`line drawing has been started, draw from old position
`to the current position
line oldx,oldy,mousex(),mousey()
`and save the current mouse position as oldx and oldy
oldx=mousex()
oldy=mousey()
else
`line drawing sequence needs to be stated
`at this point there is no old data
`so a line cannot be drawn
`but, the mouse position needs to be saved
`and the line drawing needs to be marked as started
oldx=mousex()
oldy=mousey()
started=1
endif
`this code is not needed so we can remove it
`else
`mousehold=1
endif
else
`no left mouse click means we reset the mousehold switch to off
mousehold=0
`this is new
`if the right mouse button has been pressed
`the line drawing sequence ends until another one is
`started by pressing the left mouse button
if mouseclick()=2
started=0
endif
endif
sync
loop
Once again, I hope it helps.
Oh yea, I made a couple of minor changes.
Whatever...