Skip to content

Commit

Permalink
Add: 몬스터 1마리 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
kyupid committed Dec 14, 2020
1 parent 39ab497 commit 496a20c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ class Game {
private final String PLAYER = "P ";
private final String BACKGROUND = "* ";
private final String MINE = "M ";
private final String MONSTER = "O ";

private int mine_x;
private int mine_y;
private int monster_x;
private int monster_y;

private final String[][] map = new String[11][11];
private final Scanner sc = new Scanner(System.in);
Expand All @@ -18,6 +22,7 @@ class Game {
initMap();
initPlayer();
initMine();
initMonster();

while (true) {
printAll();
Expand Down Expand Up @@ -68,6 +73,17 @@ private void getDirPlayer() {
// TODO : WASD 중 다른 방향이 들어왔을 때, 다시 입력받기
}

private void initMonster() {
monster_x = rd.nextInt(10) - 1;
monster_y = rd.nextInt(10) - 1;
map[monster_x][monster_y] = MONSTER;
while (monster_x == 5 && monster_y == 5 || monster_x == mine_x && monster_y == mine_y) {
monster_x = rd.nextInt(10) - 1;
monster_y = rd.nextInt(10) - 1;
map[monster_x][monster_y] = MONSTER;
}
}

private void initMine() {
// TODO : 나중에 마인 여러개 만들기
mine_x = rd.nextInt(10) - 1;
Expand Down

0 comments on commit 496a20c

Please sign in to comment.