Nice, I'd like AppGameKit to have more presence on YT I would make some myself but my equipment sucks and I have an attention span issue thing!!
I did a little work on celular automata a while ago using the rules by John Conways "Game Of Life" however I restricted it to a boundary and warp, I could not quite get my head round an infinite grid, lol
// Project: Game of Life
// Created: 2020-04-10
// show all errors
SetErrorMode(2)
Global Window_Width : Window_Width = 1024
Global Window_Height : Window_Height = 768
// set window properties
SetWindowTitle( "Conways - Game of Life" )
SetWindowSize( Window_Width, Window_Height, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( Window_Width, Window_Height ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
#Constant CELL_SIZE 10
#Constant GRID_WIDTH 100
#Constant GRID_HEIGHT 75
Type tCell
state
color
EndType
Type tGrid
active
gen_cur
gen_max
gen_stop_at_max
EndType
Global gConf as tGrid
Global gThisGen as tCell[GRID_WIDTH, GRID_HEIGHT]
Global gNextGen as tCell[GRID_WIDTH, GRID_HEIGHT]
gConf.active=1
gConf.gen_cur=0
gConf.gen_max=1000
gConf.gen_stop_at_max=0
NewGeneration()
do
mouse_x = GetPointerX()
mouse_y = GetPointerY()
cur_cell_x = mouse_x/CELL_SIZE
cur_cell_y = mouse_y/CELL_SIZE
if GetRawKeyPressed(KEY_ESCAPE) then end
if GetRawKeyPressed(KEY_S) then ToggleActive()
if GetRawKeyPressed(KEY_C) then ClearGeneration()
if GetRawKeyPressed(KEY_SPACE) then NewGeneration()
for cell_y=0 to GRID_HEIGHT
for cell_x=0 to GRID_WIDTH
if gConf.active
SetNextGeneration(cell_x, cell_y)
DrawCell(cell_x, cell_y, gNextGen[cell_x,cell_y].color)
else
DrawCell(cell_x, cell_y, gNextGen[cell_x,cell_y].color)
DrawGrid(cell_x, cell_y)
if (cur_cell_x=cell_x) and (cur_cell_y=cell_y)
DrawHighLight(cell_x, cell_y)
if GetRawMouseLeftState() then SetCellActive(cell_x, cell_y, 1)
if GetRawMouseRightState() then SetCellActive(cell_x, cell_y, 0)
endif
endif
next
next
inc gConf.gen_cur, 1
gThisGen=gNextGen
Print( ScreenFPS() )
Print( "Generation:" +Str(gConf.gen_cur) )
Sync()
loop
Function SetNextGeneration(cell_x, cell_y)
count = CountNeighbours(cell_x, cell_y)
state = gThisGen[cell_x, cell_y].state
if state = 0
// this cell is dead
if count = 3
gNextGen[cell_x, cell_y].state=1
gNextGen[cell_x, cell_y].color=C_GREEN
endif
else
// this cell is live
if count <2 and count >3
gNextGen[cell_x, cell_y].state=0
gNextGen[cell_x, cell_y].color=C_BLACK
elseif count = 2 or count = 3
gNextGen[cell_x, cell_y].state=1
if gNextGen[cell_x, cell_y].color = C_RED
gNextGen[cell_x, cell_y].color=C_BLUE
else
gNextGen[cell_x, cell_y].color=C_RED
endif
else
gNextGen[cell_x, cell_y].state=0
gNextGen[cell_x, cell_y].color=C_BLACK
endif
endif
EndFunction
Function CountNeighbours(x, y)
result as integer
for cell_x=-1 to 1
for cell_y=-1 to 1
cx=Mod(x+cell_x+GRID_WIDTH, GRID_WIDTH)
cy=Mod(y+cell_y+GRID_HEIGHT, GRID_HEIGHT)
result=result+gThisGen[cx, cy].state
next
next
EndFunction (result-gThisGen[x, y].state)
Function DrawCell(cell_x, cell_y, col)
x=CELL_SIZE*cell_x
y=CELL_SIZE*cell_y
//DrawEllipse(x,y, CELL_SIZE/2-2, CELL_SIZE/2-2, col, col, 1)
DrawBox(x, y, x+CELL_SIZE, y+CELL_SIZE, col, col, col, col, 1)
if gNextGen[cell_x,cell_y].state
DrawBox(x, y, x+CELL_SIZE, y+CELL_SIZE, C_GREY, C_GREY, C_GREY, C_GREY, 0)
//DrawEllipse(x, y, CELL_SIZE/2-2, CELL_SIZE/2-2, C_GREY, C_GREY, 0)
endif
EndFunction
Function DrawGrid(cell_x, cell_y)
x=CELL_SIZE*cell_x
y=CELL_SIZE*cell_y
//DrawEllipse(x, y, CELL_SIZE/2-2, CELL_SIZE/2-2, C_GREY, C_GREY, 0)
DrawBox(x, y, x+CELL_SIZE, y+CELL_SIZE, C_GREY, C_GREY, C_GREY, C_GREY, 0)
EndFunction
Function SetCellActive(cell_x, cell_y, state)
if state=1
gNextGen[cell_x,cell_y].state=1
gNextGen[cell_x,cell_y].color=C_RED
else
gNextGen[cell_x,cell_y].state=0
gNextGen[cell_x,cell_y].color=C_BLACK
endif
EndFunction
Function DrawHighLight(cell_x, cell_y)
x=CELL_SIZE*cell_x
y=CELL_SIZE*cell_y
DrawBox(x, y, x+CELL_SIZE, y+CELL_SIZE, C_GREEN, C_GREEN, C_GREEN, C_GREEN, 0)
//DrawEllipse(x, y, CELL_SIZE/2-2, CELL_SIZE/2-2, C_GREEN, C_GREEN, 0)
EndFunction
Function ToggleActive()
gConf.active=Abs(gConf.active-1)
EndFunction
Function ClearGeneration()
gConf.active=0
gConf.gen_cur=0
for cell_y=0 to GRID_HEIGHT
for cell_x=0 to GRID_WIDTH
gThisGen[cell_x, cell_y].state=0
gThisGen[cell_x, cell_y].color=C_BLACK
next
next
gNextGen=gThisGen
EndFunction
Function NewGeneration()
for cell_y=0 to GRID_HEIGHT
for cell_x=0 to GRID_WIDTH
gThisGen[cell_x, cell_y].state=random(0,1)
next
next
gConf.gen_cur=0
gConf.active=1
EndFunction
//#################################
// Color Constants
#Constant C_RED MakeColor(255,0,0)
#Constant C_BLUE MakeColor(0,0,255)
#Constant C_BLACK MakeColor(0,0,0)
#Constant C_GREEN MakeColor(0,255,0)
#Constant C_GREY MakeColor(97,97,97)
//#################################
// Key Code Constants
#Constant KEY_BACK 8
#Constant KEY_TAB 9
#Constant KEY_ENTER 13
#Constant KEY_SHIFT 16
#Constant KEY_CONTROL 17
#Constant KEY_ESCAPE 27
#Constant KEY_SPACE 32
#Constant KEY_PAGEUP 33
#Constant KEY_PAGEDOWN 34
#Constant KEY_END 35
#Constant KEY_HOME 36
#Constant KEY_LEFT 37
#Constant KEY_UP 38
#Constant KEY_RIGHT 39
#Constant KEY_DOWN 40
#Constant KEY_INSERT 45
#Constant KEY_DELETE 46
#Constant KEY_0 48
#Constant KEY_1 49
#Constant KEY_2 50
#Constant KEY_3 51
#Constant KEY_4 52
#Constant KEY_5 53
#Constant KEY_6 54
#Constant KEY_7 55
#Constant KEY_8 56
#Constant KEY_9 57
#Constant KEY_A 65
#Constant KEY_B 66
#Constant KEY_C 67
#Constant KEY_D 68
#Constant KEY_E 69
#Constant KEY_F 70
#Constant KEY_G 71
#Constant KEY_H 72
#Constant KEY_I 73
#Constant KEY_J 74
#Constant KEY_K 75
#Constant KEY_L 76
#Constant KEY_M 77
#Constant KEY_N 78
#Constant KEY_O 79
#Constant KEY_P 80
#Constant KEY_Q 81
#Constant KEY_R 82
#Constant KEY_S 83
#Constant KEY_T 84
#Constant KEY_U 85
#Constant KEY_V 86
#Constant KEY_W 87
#Constant KEY_X 88
#Constant KEY_Y 89
#Constant KEY_Z 90
#Constant KEY_F1 112
#Constant KEY_F2 113
#Constant KEY_F3 114
#Constant KEY_F4 115
#Constant KEY_F5 116
#Constant KEY_F6 117
#Constant KEY_F7 118
#Constant KEY_F8 119
#Constant KEY_COMMA 188
#Constant KEY_PERIOD 190
#Constant KEY_SLASH 191
#Constant KEY_SEMICOLON 186
#Constant KEY_APOSTROPHE 192
#Constant KEY_POUNDSIGN 222
#Constant KEY_DASH 189
#Constant KEY_EQUALS 187
#Constant KEY_LEFTBRACKET 219
#Constant KEY_RIGHTBRACKET 221
#Constant KEY_ACCENT 223
I like flow field propagation but its not as fast as AStar on huge areas but its great smaller ones.
.
Good luck with the channel.