Advertisement
Guest User

Untitled

a guest
May 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package pokemon;
  7.  
  8. import java.util.*;
  9.  
  10. public class Pokemon {
  11.  
  12. static Scanner input = new Scanner(System.in);
  13. static int playerX = 1;
  14. static int playerY = 1;
  15.  
  16.  
  17. public static void main(String[] args) {
  18.  
  19. Scene1();
  20.  
  21. }
  22.  
  23.  
  24. public static void Scene1() {
  25.  
  26. int row = 20;
  27. int col = 40;
  28. String[][] grid = new String[row][col];
  29. grid[playerY][playerX] = "X";
  30.  
  31. System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  32.  
  33. for (int i = 0; i < row; i++) {
  34. for (int j = 0; j < col; j++) {
  35. if (grid[i][j] == null) {
  36. if (i == row-row || j == col-col || i == row-1 || j == col-1) {
  37. grid[i][j] = "|";
  38. System.out.print(grid[i][j]);
  39. }
  40. else {
  41. grid[i][j] = "o";
  42. System.out.print(grid[i][j]);
  43. }
  44. }
  45. else {
  46. System.out.print(grid[i][j]);
  47. }
  48.  
  49. }
  50. System.out.println("");
  51.  
  52. }
  53.  
  54. move(grid);
  55. Scene1();
  56.  
  57. }
  58.  
  59. public static void move(String grid[][]) {
  60.  
  61. String directionMove = input.nextLine();
  62. if (directionMove.equalsIgnoreCase("w") && (!grid[playerY - 1][playerX].equals("|"))) {
  63. playerY -= 1;
  64. }
  65. else if (directionMove.equalsIgnoreCase("a") && (!grid[playerY][playerX - 1].equals("|"))) {
  66. playerX -= 1;
  67. }
  68. else if (directionMove.equalsIgnoreCase("s") && (!grid[playerY + 1][playerX].equals("|"))) {
  69. playerY += 1;
  70. }
  71. else if (directionMove.equalsIgnoreCase("d") && (!grid[playerY][playerX + 1].equals("|"))) {
  72. playerX += 1;
  73. }
  74. else {
  75. System.out.println("Please Selected w/a/s/d");
  76. move(grid);
  77. }
  78.  
  79.  
  80.  
  81. }
  82.  
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement