Been wanting to make a little program to draw lines for awhile now. So I made this. Was having some fun with it so thought I'd post it up
xres= GetDevicewidth()
yres=GetDeviceheight()
SetVirtualResolution ( xres, yres )
Type _object
image
sprite
x#
y#
width
height
EndType
for t= 1 to 10
dim ball1[t] as _object
ball1[t].sprite = CreateSprite ( 0 )
ball1[t].width=30
ball1[t].height=30
SetSpritesize( ball1[t].sprite,ball1[t].width,ball1[t].height)
SetSpritePositionbyoffset ( ball1[t].sprite, random(100,xres-100), 250)
SetSpriteDepth( ball1[t].sprite,988)
setspritecolor(ball1[t].sprite,255,255,255,100)
SetSpritePhysicsOn ( ball1[t].sprite, 2 )
SetSpriteShape ( ball1[t].sprite, 1 )
SetSpritePhysicsRestitution( ball1[t].sprite, 2 )
next t
dim beam[1] as _object
beam[1].sprite = CreateSprite ( 0 )
beam[1].width=40
beam[1].height=0
SetSpritesize( beam[1].sprite,beam[1].width,beam[1].height)
SetSpriteoffset ( beam[1].sprite, getspritewidth(beam[1].sprite)/2, 0)
SetSpritePositionbyoffset ( beam[1].sprite, 450, 250)
SetSpriteDepth( beam[1].sprite,988)
setspritecolor(beam[1].sprite,255,255,255,100)
do
if GetPointerpressed() =1
gosub createlines
endif
if getpointerstate()=1
ty=_GetDistance( getspritexbyoffset(lines1[line].sprite), getspriteybyoffset(lines1[line].sprite), getpointerx(), getpointery())
SetSpritesize( lines1[line].sprite,lines1[line].width,lines1[line].height+ty)
anglee#=ATANfull((getspritexbyoffset(lines1[line].sprite)-getpointerx()),(getspriteybyoffset(lines1[line].sprite)-getpointery()))
SetSpriteAngle( lines1[line].sprite, anglee# )
SetSpritesize( beam[1].sprite,beam[1].width,beam[1].height+ty+20)
if GetSpriteHit( getpointerx(), getpointery() )<>beam[1].sprite and ty=>10
gosub createlines
endif
setspritevisible(beam[1].sprite,1)
else
setspritevisible(beam[1].sprite,0)
endif
Sync()
loop
createlines:
line=line+1
dim lines1[line] as _object
lines1[line].sprite = CreateSprite ( 0 )
lines1[line].width=6
lines1[line].height=0
SetSpritesize( lines1[line].sprite,lines1[line].width,lines1[line].height)
SetSpriteoffset ( lines1[line].sprite, getspritewidth(lines1[line].sprite)/2, 0)
SetSpritePositionbyoffset ( lines1[line].sprite, getpointerx(), getpointery())
SetSpriteDepth( lines1[line].sprite,999)
SetSpritePhysicsOn ( lines1[line].sprite, 3 )
SetSpriteShape ( lines1[line].sprite, 2 )
SetSpritePositionbyoffset ( beam[1].sprite, getspritexbyoffset(lines1[line].sprite), getspriteybyoffset(lines1[line].sprite))
SetSpriteAngle( beam[1].sprite, anglee# )
return
Function _GetDistance( x1#, y1#, x2#, y2#)
Distance# = sqrt((x1# - x2#)^2 + (y1# - y2#)^2)
Endfunction Distance#
Put some bouncing sprites in there and made the lines physical objects.
yo