From 84c5d6e101026efa7bc05adeac809b824b15f478 Mon Sep 17 00:00:00 2001 From: sautax Date: Mon, 20 Aug 2018 18:51:12 +0200 Subject: [PATCH] infinite borders ! --- binaries/game_of_life/game_of_life.bin | Bin 55420 -> 55764 bytes game_of_life/game_of_life.ino | 8 ++-- game_of_life/update.ino | 64 +++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/binaries/game_of_life/game_of_life.bin b/binaries/game_of_life/game_of_life.bin index c55217769255af810ae101f199b188e26f9d879b..d46f17f73dab948a43745c615d2cce9718bda66c 100755 GIT binary patch delta 2800 zcmZuz3s6+o8UD}N2fLKV?)un=%eqKFc2SC;j4@G&1?1tQGLg256djElj1*c$nlUce zijS&6uMg^jI8jWrF%NF&s2Nj?jhWH3y)+RCR$bFXZ8I@zW`szU?RW07j!iu?AOAW3 z|NYe+4T znyKp?uTIT!E~If~N@Bn_Yl;1ddK#C4`5e!fuK(3aaOO-BS|&9&Hn7wsR#5UoT1YvO znxzIa0!uL0sB;Qn3*O|eEzD_89+C)`Cr?yY(NKf`Cko9u9%wpqCW@ARs3Zma>MT`B z4&SQ#{=+lfP8Q6&N2&LeS4$4fcKBGPqcXFeygKDz$^4Dv zMfEB38(QZ)RWGXSgKwIb^{~wO4SP!*DsOj*V~FQy*gY#vD#=hX&t4L!>r($iFN(JupiJ?Lg-sY;Jk zD%3q1l}eSZQOb*1(lGGlW14l$@vffHd%#%$@1Of)*cjMey;PtpU>CohEtOd-*dnRJ zI*S#_8rv#1ZQBD%rLL5l%&l$KH2>&kJvw+h0j-Z9_tRP;(Oo038aRlUC?(o>+ClC$ zM){BSY)wHEVj@TQMSKs|BL4;C3k}iYA^1eQe}FY0_bu2Hz&T(zP!=O+CbTnt%Oc-! z9WihvM%p&^IkD^;dz-udj1yP@tVEeq8%^H{yAjy#BdYbuJS{Vd2jb=I%*|Zb4a%Fgo&vp8=ZKOZmM$lJzSOj2EbCa*V1$MRG7PfhaQ^HKbSNp70)xlu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>Xq-O?)^I3=Tr0Lyh4m(Kztd z>^fZWgWwdn_c59nW_?h+G-%4)zXE%KEA 0) { if (BP) { upP = true; } @@ -91,7 +91,7 @@ void loop() { } } if (gb.buttons.pressed(BUTTON_RIGHT)) { - if (Emode) { + if (Emode&& pointer[0] < 79) { if (BP) { rightP = true; } @@ -102,7 +102,7 @@ void loop() { } } if (gb.buttons.pressed(BUTTON_LEFT)) { - if (Emode) { + if (Emode && pointer[0] > 0) { if (BP) { leftP = true; } else { diff --git a/game_of_life/update.ino b/game_of_life/update.ino index 8cd8f6c..2551285 100644 --- a/game_of_life/update.ino +++ b/game_of_life/update.ino @@ -34,12 +34,74 @@ uint8_t neighbours(uint8_t grid[80][64], uint16_t x, uint16_t y) { uint8_t sum = 0; uint16_t w = 80; uint16_t h = 64; + + if (x == 0) { + if (grid[w - 1][y]) sum += 1; + if (y == 0) { + if (grid[w - 1][h - 1]) sum += 1; + } else { + if (grid[w - 1][y - 1]) sum += 1; + } + if (y == h - 1) { + if (grid[w - 1][0]) sum += 1; + } else { + if (grid[w - 1][y + 1]) sum += 1; + } + } + + if (x == w - 1) { + if (grid[0][y]) sum += 1; + if (y == 0) { + if (grid[0][h - 1]) sum += 1; + } else { + if (grid[0][y - 1]) sum += 1; + } + if (y == h - 1) { + if (grid[0][0]) sum += 1; + } else { + if (grid[0][y + 1]) sum += 1; + } + } + + if (y == 0) { + if (grid[x][h - 1]) sum += 1; + if (x == 0) { + if (grid[w - 1][h - 1]) sum += 1; + } else { + if (grid[x - 1][h - 1]) sum += 1; + } + if (x == w - 1) { + if (grid[0][h - 1]) sum += 1; + } else { + if (grid[x + 1][h - 1]) sum += 1; + } + } + + if (y == h - 1) { + if (grid[x][0]) sum += 1; + if (x == 0) { + if (grid[w - 1][0]) sum += 1; + } else { + if (grid[x - 1][0]) sum += 1; + } + if (x == w - 1) { + if (grid[0][0]) sum += 1; + } else { + if (grid[x + 1][0]) sum += 1; + } + } + + + + + if (x != 0) { if (grid[x - 1][y]) sum += 1; if (y != h - 1) { if (grid[x - 1][y + 1]) sum += 1; } } + if (y != 0) { if (grid[x][y - 1]) sum += 1; if (x != 0) { @@ -49,9 +111,11 @@ uint8_t neighbours(uint8_t grid[80][64], uint16_t x, uint16_t y) { if (grid[x + 1][y - 1]) sum += 1; } } + if (x != w - 1) { if (grid[x + 1][y]) sum += 1; } + if (y != h - 1) { if (grid[x][y + 1]) sum += 1; if (x != w - 1) {