Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package pokemon;
- import java.util.*;
- public class Pokemon {
- static Scanner input = new Scanner(System.in);
- static int playerX = 1;
- static int playerY = 1;
- public static void main(String[] args) {
- Scene1();
- }
- public static void Scene1() {
- int row = 20;
- int col = 40;
- String[][] grid = new String[row][col];
- grid[playerY][playerX] = "X";
- 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");
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < col; j++) {
- if (grid[i][j] == null) {
- if (i == row-row || j == col-col || i == row-1 || j == col-1) {
- grid[i][j] = "|";
- System.out.print(grid[i][j]);
- }
- else {
- grid[i][j] = "o";
- System.out.print(grid[i][j]);
- }
- }
- else {
- System.out.print(grid[i][j]);
- }
- }
- System.out.println("");
- }
- move(grid);
- Scene1();
- }
- public static void move(String grid[][]) {
- String directionMove = input.nextLine();
- if (directionMove.equalsIgnoreCase("w") && (!grid[playerY - 1][playerX].equals("|"))) {
- playerY -= 1;
- }
- else if (directionMove.equalsIgnoreCase("a") && (!grid[playerY][playerX - 1].equals("|"))) {
- playerX -= 1;
- }
- else if (directionMove.equalsIgnoreCase("s") && (!grid[playerY + 1][playerX].equals("|"))) {
- playerY += 1;
- }
- else if (directionMove.equalsIgnoreCase("d") && (!grid[playerY][playerX + 1].equals("|"))) {
- playerX += 1;
- }
- else {
- System.out.println("Please Selected w/a/s/d");
- move(grid);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement