My first code I am just writting in blitz3D is my "game of life" from John Conway's idea.
It is still unfinished (not sure if I will finished it lol)
I am still nobby in blitz3D, and I dont know all commands of blitz3D and I only make code for enjoy, I am not a programmer.
I had some knoledge of basic, but for example types are new for me and I have to tray to understand them more time still. But a lot of others commands I can understand perfectly.
But I show my first code I am using for experiment with blitz3D I myself.
It is still unfinished (not sure if I will finished it lol)
I am still nobby in blitz3D, and I dont know all commands of blitz3D and I only make code for enjoy, I am not a programmer.
I had some knoledge of basic, but for example types are new for me and I have to tray to understand them more time still. But a lot of others commands I can understand perfectly.
But I show my first code I am using for experiment with blitz3D I myself.
Global pnt pnt=2 Global img_cursor Graphics 640,480,16,pnt ;Graphics 80,60,16,3 AppTitle "game of life-5" ;create grid Global x_grid Global y_grid Global cu ; size saqure Global rej ;separation 2 pinxels if grid exis Global cx Global cy Global generacion=0 Global grid run = False ; run or stoped grid = True If grid = False Then cu = 6: rej =0 Else cu = 4: rej =2 EndIf x_grid=107 y_grid=78 Dim g1%(x_grid,y_grid) Dim g2%(x_grid,y_grid) ;If pnt = 1 Then ;(only if use full screeen load a littel draw cursor image) ;HidePointer ; hide mouse ;img_cursor= LoadImage ("cursor.bmp") ;MidHandle img_cursor ;MaskImage img_cursor, 0,0,0 ;EndIf ;set buffer SetBuffer BackBuffer() makearray() ;;MAIN LOOP;; While Not KeyDown(1) If KeyDown(44) Then run = True ; press "z" =run If KeyDown(45) Then run = False ; press "x" stopped If KeyDown(46) Then ; "c" activate grid grid = True cu = 4: rej =2 EndIf If KeyDown(47) Then ; "v" no grid grid = False cu = 6: rej =0 EndIf If run = True Then gen() If run = False Then makegrid() drawMouse() EndIf Wend End ;;END;; ;;fil array random ;; Function makearray() For x=1 To x_grid For y=1 To y_grid g1%(x,y)=Rand(0,1) Next Next makegrid() Flip End Function Function gen() Cls px=0 py=0 For x=px+1 To x_grid-1+px For y=py+1 To y_grid-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 Next If c<2 Or c>3 ; if cel <2 Or c>3 rip c=0 Goto tal EndIf If c=2 c=g1%(x,y) Goto tal EndIf c=1 .tal g2%(x,y)=c Next Next makegrid() For x=px+1 To x_grid-1+px For y=py+1 To y_grid-1+py g1%(x,y)=g2%(x,y) Next Next generacion=generacion+1 Color 255,255,255 Text 0,466,"Generation: "+Str$(generacion)+" " Text 150,466,"Z = Continue X = Stop C/V = grid" Flip End Function Function makegrid() Cls x1=0 :x2=cu y1=0 :y2=cu For x=1 To x_grid y1=0 :y2=cu For y=1 To y_grid If grid=True Then If g1%(x,y)=0 Then Color 30,30,30 Rect x1,y1,x2,y2,1 EndIf If grid=False Then Color 0,0,0 EndIf If g1%(x,y)=1 Then Color 255,255,155 Rect x1,y1,x2,y2,1 EndIf y1=y1+cu+rej Next x1=x1+cu+rej Next If grid= False Then Delay 50 End Function Function drawMouse() mX% = MouseX() mY% = MouseY() lim=cu+rej ;separation 2 pinxels if grid exist cx=mX%/lim+1 cy=mY%/lim+1 Color 255,0,255 If pnt = 1 Then DrawImage img_cursor, MouseX() ,MouseY() If MouseDown(1) And cx < x_grid+1 And cy < y_grid+1 Then ; draw square g1%(cx,cy)=1 EndIf If MouseDown(2) And cx < x_grid+1 And cy < y_grid+1 Then ; delete square g1%(cx,cy)=0 EndIf Color 255,255,255 Text 0,466,"Generation: "+Str$(generacion)+" " Text 150,466,"Z = Continue X = Stop C/V = grid" Text 500,466,"X = "+cx+" Y = "+cy Flip End Function