conway's game of live 2.0

Algemene discussies en vragen omtrent Liberty BASIC programma's. Stuur zoveel mogelijk delen van listings (snippets) in als je hulp wilt.

Moderators: anthonio, Abcott

conway's game of live 2.0

Berichtdoor bluatigro » di sep 23, 2014 10:20 am

dit is n probeersel
n multy kleur conway's game of live

error :
- t wordt wel snel zwart

Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
nomainwin
dim p1( 128 * 128 ) , p2( 128 * 128 )
global true , false
true = not( false )
for x = 0 to 127
  for y = 0 to 127
    p1(in(x,y)) = int( rnd(0) * 8 )
  next y
next x
open "conways life 2.0" for graphics as #m
  #m "trapclose [quit]"
  while true
    for x = 0 to 127
      for y = 0 to 127
        scan
        for i = 0 to 2
          som(i) = 0
        next i
        for a = -1 to 1
          for b = -1 to 1
            for i = 0 to 2
              if p1(in(x+a,y+b)) and 2^i then
                som(i) = som(i) + 1
              end if
            next i
          next b
        next a
        p2(in(x,y)) = 0
        for i = 0 to 2
          if p1(in(x,y)) and 2 ^ i then
            som(i) = som(i) - 1
            if som(i) > 3 or som(i) < 2 then
              p2(in(x,y)) = p2(in(x,y)) and ( 7 - 2 ^ i )
            end if
          else
            if som(i) = 3 then
              p2(in(x,y)) = p2(in(x,y)) or 2 ^ i
            end if
          end if
        next i
        r = 0
        g = 0
        b = 0
        if p2(in(x,y))and 1 then r = 255
        if p2(in(x,y))and 2 then g = 255
        if p2(in(x,y))and 4 then b = 255
        #m "color ";r;" ";g;" ";b
        #m "backcolor ";r;" ";g;" ";b
        #m "goto ";x*4;" ";y*4
        #m "down"
        #m "boxfilled ";x*4+4;" ";y*4+4
        #m "up"
      next y
    next x
    for x = 0 to 127
      for y = 0 to 127
        p1(in(x,y)) = p2(in(x,y))
      next y
    next x
  wend
wait
[quit]
  close #m
end
function in( x , y )
  in = ( x and 127 ) + ( y and 127 ) * 128
end function
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Keer terug naar Liberty BASIC Code

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron