在地图上设置位置并在基于文本的地图中移动

时间:2016-03-22 21:27:40

标签: java dictionary multidimensional-array direction

所以我对使用java非常陌生,我正在努力使用2D阵列来制作基于文本的游戏的地图或地下城。这是我目前的代码:

import java.util.*;

public class Map
{ 
public static void main(String[] args)
{
    System.out.println("You have fallen into the dungeon");

    String [] Roomtiles = 
    {
          "You are at the entrance and may only go North.",
          "You are at the begining of the hallway, here you may go North, South, East, West.",
          "This is an achient room, the only way is East.",
          "This is an old storage, the only way is West.",
          "The hallway continues North or South.",
          "You reach a cornor and may go only West or South.",
          "You reach a room with a window, the exits are East and West.",
          "You reach a room with a massive door"    
    };

    String[] currentRoom = Roomtiles = 0;

    //North = 0, East = 1, South = 2, West = 3       
    int[][] Exits =
    {
        {1,-1,-1,-1},
        {4,3,0,2},
        {-1,1,-1,-1},
        {-1,-1,-1,1},
        {5,-1,1,-1},
        {-1,-1,4,6},
        {-1,5,-1,7},
        {-1,6,-1,-1},
    };
    System.out.printf(currentRoom);
  }
}

我已经绘制了我想要地牢的样子,但我不知道如何为初学者设置用户的位置并说明他们的位置,而且我还不知道如何让用户移动地图,我知道最多的是我需要让它们使用基本方向(比如输入n代表北方,s代表南方,分机),但我不知道如何分支实现这一点。

0 个答案:

没有答案