こんにちは
先日同じ内容を質問させていただきヒントをもらって少しだけ進歩しました。
ですがやはりわからないことが何個もあり、お尋ねしたいです。
質問内容
1、主人公(●)を移動させたら足跡のように●が増えていくのですがそれを解消するにはどうすればいいですか?
2、Mapで海や壁には●は入り込めなくするにはどうすればいいですか?
3、城のマスに●が来た時にマップをcastleにするにはどうすればいいですか?
考えていろいろ試行錯誤したのですがもう限界です・・・。
模範回答を教えてください・・・。
理解したいのでできれば説明もほしいです
お願いだらけで申し訳ありません
Java
1public class RPG { 2 3 public static void main(String[] args) { 4 System.out.println("hで左、kで右、uで上、jでした"); 5 Scanner sc = new Scanner(System.in); 6 7 Map map = new Map(); 8 String hero = "●"; 9 int x = 6; 10 int y = 18; 11 map.main[y][x] = hero; 12 //do~whileを回すためにとりあえず入れている 13 int a = 0; 14 do { 15 String temp = map.main[y][x]; 16 map.main[y][x] = hero; 17 18 19 //Map 20 for(int i = 0; i < map.main.length; i++){ 21 for(int j = 0; j < map.main[0].length; j++){ 22 if(j % 20 == 0){ 23 System.out.println(); 24 }else { 25 System.out.print(map.main[i][j]); 26 } 27 } 28 } 29 30 31 System.out.println(); 32 System.out.println("下に入力"); 33 String action = sc.next(); 34 35 switch(action){ 36 37 case "h": 38 x--; 39 break; 40 41 case "k": 42 x++; 43 break; 44 45 case "u": 46 y--; 47 break; 48 49 case "j": 50 y++; 51 break; 52 53 default: 54 break; 55 } 56 57 58 59 }while( a == 0); 60 61} 62} 63
Java
1public class Map { 2 String[][] main = {{"海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海"}, 3 {"海","海","山","山","山","山","山","山","山","山","山","山","山","草","草","草","草","草","海","海"}, 4 {"海","山","山","山","山","山","山","山","山","山","山","山","草","草","草","草","草","草","草","海"}, 5 {"海","山","山","山","山","山","山","山","山","山","草","草","草","草","草","草","草","草","草","海"}, 6 {"海","山","山","山","山","山","山","草","草","草","草","草","草","草","草","草","草","草","草","海"}, 7 {"海","森","森","森","森","森","森","森","森","森","草","草","草","草","草","草","草","草","草","海"}, 8 {"海","森","森","森","森","森","森","森","森","森","森","草","草","草","草","草","草","草","草","海"}, 9 {"海","森","森","森","森","森","森","森","森","森","草","草","草","草","草","草","草","草","草","海"}, 10 {"海","草","森","森","森","森","森","森","森","森","草","草","草","草","草","草","草","草","草","海"}, 11 {"海","草","草","草","草","草","草","草","草","草","草","草","草","草","草","草","草","草","草","海"}, 12 {"海","草","草","草","草","城","草","草","草","草","草","草","草","草","草","草","草","草","草","海"}, 13 {"海","草","草","草","草","道","草","草","草","草","草","草","草","草","草","草","森","森","森","海"}, 14 {"海","草","草","草","草","道","草","草","草","草","草","草","草","草","草","森","森","森","森","海"}, 15 {"海","草","草","草","草","道","草","草","草","草","草","草","草","草","草","草","森","森","森","海"}, 16 {"海","草","草","草","道","道","道","道","道","道","道","道","道","街","草","草","草","草","草","海"}, 17 {"海","草","草","草","道","草","草","草","草","草","草","草","草","草","草","草","草","草","草","海"}, 18 {"海","草","草","草","道","草","草","草","草","草","草","草","草","草","草","草","草","草","草","海"}, 19 {"海","草","草","草","道","草","草","草","草","草","草","草","草","草","草","草","草","草","草","海"}, 20 {"海","海","草","道","道","道","草","草","草","草","草","草","草","草","草","草","草","草","海","海"}, 21 {"海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海","海"}}; 22 23 String[][] town = {{"出","出","出","出","出","出","出","出","出","出"}, 24 {"出","草","草","草","草","草","草","草","草","出"}, 25 {"出","草","武","草","草","草","草","道","草","出"}, 26 {"出","草","草","草","草","草","草","草","草","出"}, 27 {"出","草","草","草","草","草","草","草","草","出"}, 28 {"出","草","防","草","草","草","草","宿","草","出"}, 29 {"出","草","草","草","草","草","草","草","草","出"}, 30 {"出","草","草","草","草","草","草","草","草","出"}, 31 {"出","草","草","草","草","草","草","草","草","出"}, 32 {"出","出","出","出","出","出","出","出","出","出"}}; 33 34 35 String[][] castle = {{"壁","壁","壁","壁","壁","壁","壁","壁","壁","壁"}, 36 {"壁","壁","壁","壁","王","壁","壁","壁","壁","壁"}, 37 {"壁","道","道","道","道","道","道","道","道","壁"}, 38 {"壁","道","道","道","道","道","道","道","道","壁"}, 39 {"壁","道","壁","道","道","道","道","壁","道","壁"}, 40 {"壁","道","道","道","道","道","道","道","道","壁"}, 41 {"壁","道","道","道","道","道","道","道","道","壁"}, 42 {"壁","道","壁","道","道","道","道","壁","道","壁"}, 43 {"壁","道","壁","道","道","道","道","壁","道","壁"}, 44 {"壁","壁","壁","壁","出","出","壁","壁","壁","壁"}}; 45 46 47} 48
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2015/07/23 09:52
2015/07/23 10:05
2015/07/23 10:20 編集
2015/07/23 10:44
2015/07/23 11:10
2015/07/23 11:22
2015/07/23 11:23
2015/07/23 11:45
2015/07/23 12:01
2015/07/23 13:16
2015/07/23 22:57 編集
2015/07/24 00:10 編集
2015/07/24 01:28
2015/07/24 02:03
2015/07/24 05:25
2015/07/24 07:44 編集
2015/07/25 09:12
2015/07/25 09:18
2015/07/25 21:31
2015/07/26 00:21
2015/07/26 01:25