Qbasicnews.com

Full Version: Got a problem with porting a program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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$ = ""
Do you mean that a single drop should erase the lines? Because of the fact that you are using random numbers, there has to be some way that you cover every single pixel of the screen, and it doesn't seem like your code has any such way of making sure of this.
Zap repsonded to this when you posted it at fbtk (click here)

Quote:You call to POINT is wrong,

you're meant to do like this:

Code:
point(x,y)

but you only give it one argument, the y-coordinate.



Try doing

Code:
if point(dropx(count),dropy(count)+1) = 0 then

instead.