10-15-2023, 04:07 PM
(10-15-2023, 11:50 AM)bplus Wrote: Y'all did see the code that skipped the IF test altogether, just added in everything and then subtracted out the one thing not wanted. Time wise, BIG savings!
I like. I similar in a life-like program. (and yes I have a honking load of if thens)
Code: (Select All)
Sub update_cell (sx, sy)
'check each cell for neighbors and update life
_Source s0
_Dest s1
ds = -1 'set to -1 because we are going to count the cell itself and ignore it this way
If sx > 1 Then x0 = sx - 1 Else x0 = 0
If sy > 1 Then y0 = sy - 1 Else y0 = 0
If sx < xmax - 1 Then x1 = sx + 1 Else x1 = xmax - 1
If sy < ymax - 1 Then y1 = sy + 1 Else y1 = ymax - 1
For y = y0 To y1
For x = x0 To x1
If Point(x, y) <> _RGB32(0, 0, 0) Then ds = ds + 1
Next
Next
Select Case ds
Case 0, 1
PSet (sx, sy), _RGB32(0, 0, 0)
Case 2
PSet (sx, sy), klr
Case 3
If Point(sx, sy) = _RGB32(0, 0, 0) Then PSet (sx, sy), klr Else PSet (sx, sy), klr
Case Is > 3
PSet (sx, sy), _RGB32(0, 0, 0)
End Select
End Sub