Hi, thought I'd throw some ideas in here.
Quote: "the user should be able to click somewhere on the screen, and then clicks another pleace on the screen and it makes a line from the to seperate clicks"
What you need are flags that hold the current state of the above sequence. You need a flag that shows the left mouse button is currently being pressed, so the user has to release the button in order to place the second point (or a new line). You also need a second flag to record whether the first or second point of the line has been or is being placed. See the demo below for a way of implementing this (I'm sure there are other ideas lurking in the dark and ancient depths of the forum somewhere).
sync on
sync rate 60
set window off
mouse_clicked = 0 :`this flag shows whether or not the left mouse button has been clicked (goes to 1 when the button has been pressed)
start_line = 0 :`this flag shows whether or not the start of the line has been chosen (goes to 1 when the start point for the line has been selected)
`this bitmap will be used to hold the drawing
create bitmap 1, screen width(), screen height()
`set the current bitmap to the screen
set current bitmap 0
`start of loop
do
`clear the screen
cls
x = mousex()
y = mousey()
`if the left mouse button is not currently being pressed
if mouse_clicked = 0
`detects that you have pressed the left hand mouse button
if mouseclick() = 1
mouse_clicked = 1 :`shows that the left mouse button has been pressed
if start_line = 0
`this tells the program that you have selected the start point of the line
start_line = 1
`this hold the coordinates for the start of the line
sx = x
sy = y
else
`this resets the flag to say that the end point of the line has been placed
start_line = 0
`set the current bitmap to the one that was created (i.e not the screen)
set current bitmap 1
`draw the line (to bitmap 1)
line sx,sy, x,y
`set the bitmap back to the screen
set current bitmap 0
endif
endif
endif
`if the mouse button is not being pressed then set the flag mouse_clicked to zero
`this means that the user has to release the button to be able to select the second point of the line
`(or indeed to start a new line)
if mouseclick() = 0 then mouse_clicked = 0
`copy the drawing (bitmap 1) to the screen (bitmap 2)
copy bitmap 1,0
`if the first point of the line has bee placed then draw a "rubber band" line
if start_line = 1
line sx,sy, x,y
endif
`print some stuff to the screen
set cursor 0,0
print "mouse x : ", x
print "mouse y : ", y
print
print "start_line : ", start_line
print "mouse_clicked : ", mouse_clicked
`update the screen
sync
loop
You'll notice in the code that I have created an off screen bitmap that the user draws to and is then copied to the screen. This allows the use of a "rubber band" line and for any text / icons to be printed to the screen without deletely what has been drawn. I don't know if this is something you sorted out yourself but I thought I'd include it here for the sake of completeness.
Hope this helps.
Edit: only just noticed this:
Quote: " now i only need help to make the lines start from second click"
A little mod to my above demo and I think this is what you want. Use left hand mouse button to draw the lines and then right hand mouse button to finish drawing the lines. You can then keep drawing lines.
sync on
sync rate 60
set window off
mouse_clicked = 0 :`this flag shows whether or not the left mouse button has been clicked (goes to 1 when the button has been pressed)
start_line = 0 :`this flag shows whether or not the start of the line has been chosen (goes to 1 when the start point for the line has been selected)
`this bitmap will be used to hold the drawing
create bitmap 1, screen width(), screen height()
`set the current bitmap to the screen
set current bitmap 0
`start of loop
do
`clear the screen
cls
x = mousex()
y = mousey()
`if the left mouse button is not currently being pressed
if mouse_clicked = 0
`detects that you have pressed the left hand mouse button
if mouseclick() = 1
mouse_clicked = 1 :`shows that a mouse button has been pressed
if start_line = 0
`this tells the program that you have selected the start point of the line
start_line = 1
`this hold the coordinates for the start of the line
sx = x
sy = y
else
`set the current bitmap to the one that was created (i.e not the screen)
set current bitmap 1
`draw the line (to bitmap 1)
line sx,sy, x,y
sx = x
sy = y
`set the bitmap back to the screen
set current bitmap 0
endif
endif
`if right hand mouse button is pressed finish current line drawing command
if mouseclick() = 2
mouse_clicked = 1 :``shows that a mouse button has been pressed
start_line = 0 :`this resets the flag to say that the end point of the line has been placed
endif
endif
`if the mouse button is not being pressed then set the flag mouse_clicked to zero
`this means that the user has to release the button to be able to select the second point of the line
`(or indeed to start a new line)
if mouseclick() = 0 then mouse_clicked = 0
`copy the drawing (bitmap 1) to the screen (bitmap 2)
copy bitmap 1,0
`if the first point of the line has bee placed then draw a "rubber band" line
if start_line = 1
line sx,sy, x,y
endif
`print some stuff to the screen
set cursor 0,0
print "mouse x : ", x
print "mouse y : ", y
print
print "start_line : ", start_line
print "mouse_clicked : ", mouse_clicked
`update the screen
sync
loop