LOG came in handy for me recently when I was reducing LOC (Lines Of Code) for Classic 2048 Game from Dav's version.
He had all these lines to create a shaded Backcolor for a tile, to get darker as value gets higher:
I said to myself if I didn't mind going color blind a bit, I could shade tiles darker by finding the power of 2 that the Board(x, y) value and do bg& in shades of grey: _RGB32(OneValue0to255) = shade of grey
Mission accomplished!
Here is a little formula for getting Power in X of Y. In example above, what power of 2 is Board(x, y) value?
PowerX = Log(Y)/Log(X)
Check if Y is 0 first though to avoid error.
He had all these lines to create a shaded Backcolor for a tile, to get darker as value gets higher:
Code: (Select All)
Select Case board(x, y)
Case 2: bg& = _RGB(239, 229, 218)
Case 4: bg& = _RGB(236, 224, 198)
Case 8: bg& = _RGB(241, 177, 121)
Case 16: bg& = _RGB(236, 141, 84)
Case 32: bg& = _RGB(247, 124, 95)
Case 64: bg& = _RGB(233, 89, 55)
Case 128: bg& = _RGB(242, 217, 107)
Case 256: bg& = _RGB(238, 205, 96)
Case 512: bg& = _RGB(238, 205, 96)
Case 1024: bg& = _RGB(238, 205, 96)
Case 2048: bg& = _RGB(238, 205, 96)
Case 4096: bg& = _RGB(121, 184, 226)
Case 8192: bg& = _RGB(121, 184, 226)
Case 16384: bg& = _RGB(121, 184, 226)
Case 32768: bg& = _RGB(60, 64, 64)
Case Else: bg& = _RGB(204, 192, 180)
End Select
I said to myself if I didn't mind going color blind a bit, I could shade tiles darker by finding the power of 2 that the Board(x, y) value and do bg& in shades of grey: _RGB32(OneValue0to255) = shade of grey
Code: (Select All)
If Board(x, y) Then power = Log(Board(x, y)) / Log(2) Else power = 0
bg& = _RGB32(255 - 17 * power) ' =set to shade of grey, the higher the value the darker
Mission accomplished!
Here is a little formula for getting Power in X of Y. In example above, what power of 2 is Board(x, y) value?
PowerX = Log(Y)/Log(X)
Check if Y is 0 first though to avoid error.
b = b + ...