Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: rain_storm on March 08, 2007

Title: Matrix Effect
Post by: rain_storm on March 08, 2007

Code: [Select]
open window 640, 512
resx = 80
resy = 64
size = 640/resx
dim buffer(resx,resy)
dim drop(resx), fall(resx)

for a = 0 to resx
  drop(a) = rnd(resy)
  fall(a) = rnd(0.5)+0.5
next

repeat
  setdispbuf draw
  draw = 1 - draw
  setdrawbuf draw
  a = 0
  for x = 0 to resx a = a + size
    drop(x) = drop(x) + fall(x)
    if (drop(x) > resy) then
      drop(x) = drop(x) - resy
      fall(x) = rnd(0.5) + 0.5
    fi
    buffer(x,drop(x)) = 255
    b = 0
    for y = 0 to resy b = b + size
      c = buffer(x,y)
      setrgb 1, 0, c, 0
      fill box a,b to a-size,b-size
      buffer(x,y) = c - 4
    next
  next
until (0=1)

sub rnd(range) rnd$ = time$ : length = len(rnd$)
  local rnd$(length) : static rnd, seed
  for l = 1 to length
    if (mid$(rnd$,l,1) = "-") then rnd$ = left$(rnd$,l-1) + " " + right$(rnd$,length-l)
    else rnd$ = left$(rnd$,l-1) + str$(9-val(mid$(rnd$,l,1))) + right$(rnd$,length-l)
    fi
  next l
  seed = ran(rnd) : if (seed < 1) seed = range + 1
  random = token(rnd$, rnd$())
  for r = 1 to random rnd = val(rnd$(r)) + rnd next
  rnd = ran(rnd) / ran(seed) : return range*frac(rnd)
end sub
[/font]
Title: Re: Matrix Effect
Post by: Shockwave on March 08, 2007
Nice one :)
Title: Re: Matrix Effect
Post by: Paul on March 08, 2007
cool!
Title: Re: Matrix Effect
Post by: rain_storm on March 08, 2007
Cheers nice to see that you guys like this