06-08-2005, 07:49 PM
I wrote this simple program a while ago in basic, ported it to C
and now i want to port it back to Freebasic.
But i can't get it to work properly, the drops fall down from the top but should erase the lines i draw on the screen. Anyone can help me with what i'm doing wrong?
dim shared dropx( 0 to 3000 ) as integer
dim shared dropy( 0 to 3000 ) as integer
screen 18
randomize timer
chance = 0
chance2 = 0
count = 0
line (20, 100)-(400,200), 6
line (20, 101)-(400,201), 6
for count = 0 to 3000
chance = rnd * 639+1
chance2 = rnd * 199+1
dropx(count) = chance
dropy(count) = chance2
next count
do
for count = 0 to 3000
pset (dropx(count), dropy(count)), 0
if point(dropy(count)+1) = 0 then
dropy(count) = dropy(count) + 1
chance = rnd * 20
if chance < 2 then if POINT(dropx(count)-1) = 0 then dropx(count) = dropx(count) - 1
if chance > 18 then if POINT(dropx(count)+1) = 0 then dropx(count) = dropx(count) + 1
end if
if point(dropy(count)+1) > 0 then
chance = rnd * 1
if chance = 0 then if POINT(dropx(count)-1) = 0 then dropx(count) = dropx(count) - 1
if chance = 1 then if POINT(dropx(count)+1) = 0 then dropx(count) = dropx(count) + 1
end if
pset(dropx(count), dropy(count)), 12
next count
sleep 1
loop while inkey$ = ""
and now i want to port it back to Freebasic.
But i can't get it to work properly, the drops fall down from the top but should erase the lines i draw on the screen. Anyone can help me with what i'm doing wrong?
dim shared dropx( 0 to 3000 ) as integer
dim shared dropy( 0 to 3000 ) as integer
screen 18
randomize timer
chance = 0
chance2 = 0
count = 0
line (20, 100)-(400,200), 6
line (20, 101)-(400,201), 6
for count = 0 to 3000
chance = rnd * 639+1
chance2 = rnd * 199+1
dropx(count) = chance
dropy(count) = chance2
next count
do
for count = 0 to 3000
pset (dropx(count), dropy(count)), 0
if point(dropy(count)+1) = 0 then
dropy(count) = dropy(count) + 1
chance = rnd * 20
if chance < 2 then if POINT(dropx(count)-1) = 0 then dropx(count) = dropx(count) - 1
if chance > 18 then if POINT(dropx(count)+1) = 0 then dropx(count) = dropx(count) + 1
end if
if point(dropy(count)+1) > 0 then
chance = rnd * 1
if chance = 0 then if POINT(dropx(count)-1) = 0 then dropx(count) = dropx(count) - 1
if chance = 1 then if POINT(dropx(count)+1) = 0 then dropx(count) = dropx(count) + 1
end if
pset(dropx(count), dropy(count)), 12
next count
sleep 1
loop while inkey$ = ""