Skip to content

Commit

Permalink
infinite borders !
Browse files Browse the repository at this point in the history
  • Loading branch information
nponsard committed Aug 20, 2018
1 parent f8d85c4 commit 84c5d6e
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
Binary file modified binaries/game_of_life/game_of_life.bin
Binary file not shown.
8 changes: 4 additions & 4 deletions game_of_life/game_of_life.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void loop() {
}

if (gb.buttons.pressed(BUTTON_DOWN)) {
if (Emode) {
if (Emode && pointer[1] < 63) {
if (BP) {
downP = true ;
}
Expand All @@ -81,7 +81,7 @@ void loop() {
}
}
if (gb.buttons.pressed(BUTTON_UP)) {
if (Emode) {
if (Emode && pointer[1] > 0) {
if (BP) {
upP = true;
}
Expand All @@ -91,7 +91,7 @@ void loop() {
}
}
if (gb.buttons.pressed(BUTTON_RIGHT)) {
if (Emode) {
if (Emode&& pointer[0] < 79) {
if (BP) {
rightP = true;
}
Expand All @@ -102,7 +102,7 @@ void loop() {
}
}
if (gb.buttons.pressed(BUTTON_LEFT)) {
if (Emode) {
if (Emode && pointer[0] > 0) {
if (BP) {
leftP = true;
} else {
Expand Down
64 changes: 64 additions & 0 deletions game_of_life/update.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 84c5d6e

Please sign in to comment.