Sorry for late reply, i made cube 1,0 so it went to 3d space and made line drawing inside the loop, but now i got new issue. I'm trying to make end of the lines snap when they're close to each other so there would be a possibilty to make closed area. Well, no success this far, any idea how i can make the mouse snap to the nearest end?
code:
sync on
sync rate 60
make object cube 1,0
load image "cursor.bmp",1
Type kaapeli
x1 as integer
y1 as integer
x2 as integer
y2 as integer
endtype
dim johto(10000) as kaapeli
for i = 1 to 10000
johto(i).x1 = 0
johto(i).y1 = 0
johto(i).x2 = 0
johto(i).y2 = 0
next i
johtonum = 1
tool = 0
toolcd# = 0
vaihdecd# = 0
color backdrop RGB(255,255,255)
disable escapekey
hide mouse
sprite 1,0,0,1
x = 0
y = 0
do
inc x,mmx
inc y,mmy
mx=mousex()
my=mousey()
sprite 1,x,y,1
offset sprite 1,sprite width(1)/2,sprite height(1)/2
sx = sprite x(1)
sy = sprite y(1)
if tool > 0 and escapekey()=1
tool = 0
endif
mmx = mousemovex()
mmy = mousemovey()
position mouse sprite x(1),sprite y(1)
if vaihdecd# > 0 and mouseclick()=0
vaihdecd# = vaihdecd# - 0.1
endif
if vaihdecd# < 0
vaihdecd# = 0
endif
if toolcd#>0
dec toolcd#,10
endif
if toolcd#<0
toolcd#=0
endif
if KEYSTATE(2)=1 and toolcd# = 0
tool = 0
toolcd# = 10
inc tool,1
endif
if tool = 1
set cursor 10,10
print "Johdon piirto"
endif
if tool = 1 and vaihde=0 and mouseclick()=1 and vaihdecd# = 0
vaihdecd# = 3
inc vaihde,1
johto(johtonum).x1 = sprite x(1)
johto(johtonum).y1 = sprite y(1)
endif
if vaihde = 1 and mouseclick()=1 and vaihdecd# = 0 and tang1 = 0 and tang2 = 0
vaihde = 0
johto(johtonum).x2 = sprite x(1)
johto(johtonum).y2 = sprite y(1)
inc johtonum,1
endif
if tool = 1 and vaihde=1
johto(johtonum).x2 = sprite x(1)
johto(johtonum).y2 = sprite y(1)
endif
if johto(johtonum).x1 <> 0 and johto(johtonum).y1 <> 0
line johto(johtonum).x1,johto(johtonum).y1,johto(johtonum).x2,johto(johtonum).y2
endif
if vaihde = 1 and returnkey()=1 and tool = 1
tool = 0
vaihde = 0
johto(johtonum).x2 = johto(johtonum).x1
johto(johtonum).y2 = johto(johtonum).y1
endif
for p = 1 to johtonum
ink RGB(0,0,0), RGB(255,255,255)
line johto(p).x1,johto(p).y1,johto(p).x2,johto(p).y2
next p
for r = 1 to johtonum-1
if sprite x(1)> johto(r).x1-5 and sprite x(1)<johto(r).x1+5 and sprite y(1)< johto(r).y1+5 and sprite y(1)>johto(r).y1-5 and tool =1
circle johto(r).x1,johto(r).y1,5
sprite 1, johto(r).x1,johto(r).y1,1
position mouse sprite x(1),sprite y(1)
tang1 = 1
else
tang1 = 0
endif
if vaihde = 1 and mouseclick()=1 and vaihdecd# = 0 and tang1 = 1 and tang2 = 0
vaihde = 0
johto(johtonum).x2 = johto(r).x1
johto(johtonum).y2 = johto(r).y1
inc johtonum,1
endif
if sprite x(1)> johto(r).x2-5 and sprite x(1)<johto(r).x2+5 and sprite y(1)< johto(r).y2+5 and sprite y(1)>johto(r).y2-5 and tool =1
circle johto(r).x2,johto(r).y2,5
sprite 1, johto(r).x2,johto(r).y2,1
position mouse sprite x(1),sprite y(1)
endif
if vaihde = 1 and mouseclick()=1 and vaihdecd# = 0 and tang1 = 0 and tang2 = 1
vaihde = 0
johto(johtonum).x2 = johto(r).x2
johto(johtonum).y2 = johto(r).y2
inc johtonum,1
endif
next r
set cursor 10,20
print
print johtonum
print vaihde
sync
loop
Sorry the code is a bit messy, since i quited too early yesterday. Also you can ignore the sprite commands, they'r not needed and you can select line drawing tool by pressing 1 (text appears "Johdon piirto" which means line drawing.
anyhow, if you like to use the sprite, it's attached.
EDIT: Oh, there's existing command "position mouse x,y", so problem solved
EDIT2: Oh, no it's not. The mouse still not snap to the end of the line, i also updated the code. Seems like the position mouse can't be forced to the sprite.