Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- switch (direction) {
- case EAST:
- if (x < width - 1) {
- return cells[y][x + 1];
- }
- break;
- case NORTH:
- if (y > 0) {
- return cells[y - 1][x];
- }
- case NORTHEAST:
- if (x < width - 1 && y > 0) {
- return cells[y - 1][x + 1];
- }
- break;
- case NORTHWEST:
- if (x > 0 && y > 0) {
- return cells[y - 1][x - 1];
- }
- break;
- case SOUTH:
- if (y < height - 1) {
- return cells[y + 1][x];
- }
- break;
- case SOUTHEAST:
- if (x < width - 1 && y < height - 1) {
- return cells[y + 1][x + 1];
- }
- break;
- case SOUTHWEST:
- if (x > 0 && y < height - 1) {
- return cells[y + 1][x - 1];
- }
- break;
- case WEST:
- if (x > 0) {
- return cells[y][x - 1];
- }
- break;
- }
- // statische Randbedingungen:
- return new Cell(State.DEAD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement