Game of life by etereo30th Aug 2007 20:56
|
---|
Summary A free version of mine of game of life. I am not the first who write this game and I supose someone will do better than I. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem Ejemplo del juego de la vida rem example of game of life rem set display mode 320,200,16 set display mode 640,480,16 tx=640/2-40 ty=480/2-40 Rem puntos X Y Izquierda-arriba px=0 py=0 x=timer() randomize x DIM g1(tx,ty) Dim g2(tx,ty) generacion=0 CLS sync rate 4 sync on FOR x=px TO tx FOR y=py TO ty g1(x,y)=RND(5) NEXT y x=x+5 :rem aqui va bien de 2 a 6 NEXT x DO sync rate 10 FOR x=px+1 TO tx-1+px FOR y=py+1 TO ty-1+py c=0 FOR x1=px-1 TO 1+px FOR y1=py-1 TO 1+px IF x1<>0 OR y1<>0 c=c+g1(x+x1,y+y1) ENDIF NEXT y1 NEXT x1 IF c<2 OR c>3 c=0 GOTO tal ENDIF IF c=2 c=g1(x,y) GOTO tal ENDIF c=1 tal: g2(x,y)=c rem COLOR c if c=0 Then ink rgb(0,100,100),0 `` if c=1 Then ink rgb(255,255,255),1 DOT x*2,y*2 rem DOT x+2,y+2 :rem asi lo hace sin huecos ink rgb(0,255,0),1 NEXT y NEXT x FOR x=px+1 TO tx-1+px FOR y=py+1 TO ty-1+py g1(x,y)=g2(x,y) NEXT y NEXT x sync generacion=generacion+1 gosub info if mouseclick()=2:exit:endif LOOP info: ink 1,1 : rem Set the ink to black and paper color to black box 0,465,639,479 : rem draw a black box on screen which will clear away old message ink rgb(244,214,210),1 : rem Set the ink to white and paper color to black rem draw new message text 0,465,"Generation: "+str$(generacion)+" " return |