Computer Science Canada

lightning

Author:  Mazer [ Thu May 01, 2003 2:55 pm ]
Post subject:  lightning

k, i made this a few days ago and posted it on the ooturing boards while this one was still down

Author:  DarkHelmet [ Thu May 01, 2003 3:04 pm ]
Post subject: 

that's pretty cool. good job

Author:  Tony [ Thu May 01, 2003 5:15 pm ]
Post subject: 

looks cool.
+200Bits

Author:  Homer_simpson [ Thu May 01, 2003 10:26 pm ]
Post subject: 

code:
const maxdetectors := 20
const numberofbolts := 2
const detectiondistance := 100
function distance (x1, y1, x2, y2 : int) : int
    result round (((x1 - x2) ** 2 + (y1 - y2) ** 2) ** .5)
end distance
colorback (16)
cls
View.Set ("offscreenonly")
var mx, my, mb : int
var x, y, xx1, yy1, xx2, yy2 := 300
procedure calcline (x1, y1, x2, y2 : int, var xx1, yy1, xx2, yy2 : int)
    var slope : real
    var xx := (x2 - x1) / 3
    if x2 - x1 not= 0 then
        slope := (y2 - y1) / (x2 - x1)
    else
        slope := 999999999
    end if
    yy1 := round (y1 + (xx * slope))
    xx1 := round (x1 + xx)
    xx := (x2 - x1) / (3 / 2)
    yy2 := round (y1 + (xx * slope))
    xx2 := round (x1 + xx)
end calcline
function random (m, x : int) : int
    var rr : int
    randint (rr, m, x)
    result rr
end random
var ysh1 := 0
var ysh2 := 0
type detectors :
    record
        x, y : int
    end record
var arr : array 1 .. maxdetectors of detectors

for i : 1 .. maxdetectors
    arr (i).x := random (1, 640)
    arr (i).y := random (1, 400)
end for

loop
    mousewhere (mx, my, mb)
    for i : 1 .. maxdetectors
        if distance (mx, my, arr (i).x, arr (i).y) < detectiondistance then
            calcline (mx, my, arr (i).x, arr (i).y, xx1, yy1, xx2, yy2)
            for ii : 1 .. numberofbolts
                ysh1 := random (-10, 10)
                drawline (mx, my, xx1 + ysh1, yy1 + ysh1, 54)
                ysh2 := random (-10, 10)
                drawline (xx1 + ysh1, yy1 + ysh1, xx2 + ysh2, yy2 + ysh2, 52)
                drawline (xx2 + ysh2, yy2 + ysh2, arr (i).x, arr (i).y, white)
            end for
        end if
        drawfilloval (arr (i).x, arr (i).y, 10, 10, random (1, 255))
    end for
    drawfilloval (300, 300, 10, 10, 12)
    View.Update
    cls
    exit when hasch
end loop

this is my version of lightning i made it based on the same idea with a different method try changeing
const maxdetectors := 20
const numberofbolts := 2
const detectiondistance := 100
they will change the outpput

Author:  ZeroKelvin [ Fri May 02, 2003 10:11 am ]
Post subject: 

i need turing 4 can someone share or tell me where to get it?

Author:  Homer_simpson [ Fri May 02, 2003 12:35 pm ]
Post subject: 

Add these two lines
code:
    drawfillstar (mx - 15, my - 15, mx + 15, my + 15, 53)
    drawoval (mx, my, 15, 15, 53)

under
code:
     mousewhere (mx, my, mb)
[/code]


: