break on
;
; KIXTART 4.01
; KIXFORMS BUILD 4 - http://kixtart.tripod.ca/kixforms.zip
;
; Written by cj, multilated by shawn
;
srnd(@ticks)
$form = createobject("kixtart.form")
$width = $form.clientwidth
$height = $form.clientheight
$form.caption = "Shawn"
$form.backcolor = 0
$label1 = $form.label(175,0,300,40,"KiXtart Version 4.01")
$label1.visible=0
$label1.top=0
$label1.forecolor = $form.rgb(0,191,255)
$label1.fontsize = 24
$label1.fontname = "Times Roman New"
$label2 = $form.label(0,175,300,40,"KiXforms Build 4")
$label2.visible=0
$label2.left=0
$label2.forecolor = $form.rgb(127,255,212)
$label2.fontsize = 24
$label2.fontname = "Times Roman New"
$label3 = $form.label(0,250,300,40,"The Bouncing Line")
$label3.visible=0
$label3.forecolor = $form.rgb(250,250,10)
$label3.fontsize = 24
$label3.fontname = "Times Roman New"
$form.visible=1
$label1.visible=1
for $top=0 to 100 step 2
$label1.top=$top
next
$label2.visible=1
for $left=-100 to 190 step 2
$label2.left=$left
next
$label3.visible=1
for $left=$form.clientwidth to 180 step -2
$label3.left=$left
next
$start = $form.commandbutton(255,350,100,40,"START")
while $form.getevent
if $start.click
bounce()
endif
loop
exit 1
function bounce()
$label1 = 0
$label2 = 0
$label3 = 0
$start = 0
$x1=20
$y1=40
$x2=150
$y2=180
$s=3 ; max speed
$x1d=1
$y1d=2
$x2d=-1
$y2d=-2
$ol=0 ; start with mode 0, left click to change mode...
$lc = $form.rgb(255,255,255) ; line colour, cycle with right click, used in OL mode 2 only
do
; old line
select
case $ol=0 ; erase old line mode
$form.forecolor = 0 ; black
case $ol=1 ; multicoloured trail mode
$form.forecolor = $form.rgb(rnd(255),rnd(255),rnd(255))
case $ol=2 ; single coloured trail
$red=$red+1;rnd(10)
if $red > 255
$red=rnd(255)
endif
$blue=$blue+1;rnd(10)
if $blue > 255
$blue=rnd(255)
endif
$green=$green+1;rnd(10)
if $green > 255
$green=rnd(255)
endif
$form.forecolor = $form.rgb($red,$green,$blue)
endselect
$form.line($x1, $y1, $x2, $y2) ; draw old line
; new location
$x1=$x1+$x1d
if $x1 > $width
$x1d=0-(rnd($s)+1)
endif
if $x1<0
$x1d=rnd(2)+1
endif
$y1=$y1+$y1d
if $y1>$height
$y1d=0-(rnd($s)+1)
endif
if $y1<0
$y1d=rnd(2)+1
endif
$x2=$x2+$x2d
if $x2>$width
$x2d=0-(rnd($s)+1)
endif
if $x2<0;
$x2d=rnd(2)+1
endif
$y2=$y2+$y2d
if $y2>$height
$y2d=0-(rnd($s)+1)
endif
if $y2<0;
$y2d=rnd(2)+1
endif
; draw live line
$form.forecolor = $form.rgb(255,255,255)
$form.line($x1, $y1, $x2, $y2)
if $form.peekevent
if $form.visible = 0
return
endif
if $form.mousedown
if $form.mousebutton = 1
select
case $ol = 0
$form.caption = "Random-Color Mode"
$ol = 1
case $ol = 1
$form.caption = "Cycle-Color Mode"
$red=rnd(255)
$green=rnd(255)
$blue=rnd(255)
$ol=2
case $ol = 2
$form.caption = "Erase Mode"
$ol = 0
endselect
endif
endif
endif
$form.delay(3)
until 1=0
endfunction