Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. switch (direction) {
  2. case EAST:
  3. if (x < width - 1) {
  4. return cells[y][x + 1];
  5. }
  6. break;
  7. case NORTH:
  8. if (y > 0) {
  9. return cells[y - 1][x];
  10. }
  11. case NORTHEAST:
  12. if (x < width - 1 && y > 0) {
  13. return cells[y - 1][x + 1];
  14. }
  15. break;
  16. case NORTHWEST:
  17. if (x > 0 && y > 0) {
  18. return cells[y - 1][x - 1];
  19. }
  20. break;
  21. case SOUTH:
  22. if (y < height - 1) {
  23. return cells[y + 1][x];
  24. }
  25. break;
  26. case SOUTHEAST:
  27. if (x < width - 1 && y < height - 1) {
  28. return cells[y + 1][x + 1];
  29. }
  30. break;
  31. case SOUTHWEST:
  32. if (x > 0 && y < height - 1) {
  33. return cells[y + 1][x - 1];
  34. }
  35. break;
  36. case WEST:
  37. if (x > 0) {
  38. return cells[y][x - 1];
  39. }
  40. break;
  41. }
  42. // statische Randbedingungen:
  43. return new Cell(State.DEAD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement