repl.it
@AZRIELGIESWEIN/

Super 2D Array Game with Java Skill Building

Java

No description

fork
loading
Files
  • Main.java
  • comments.java
  • Ded.java
  • Enemy.java
  • Player.java
  • Wall.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
      
import java.util.ArrayList;
import java.util.Scanner;  
import java.util.Random;

class Main {
  
  //int x,y;
    
  // public int getx (){
  //   return this.x;
  // }
  // public int gety (){
  //   return this.y;
  // }
  
  public static void main(String[] args) {
    Scanner bot = new Scanner(System.in);
    
  
    
    
    Player p = new Player(10,20);
    Enemy e = new Enemy(10,0);
    Ded d = new Ded(10,20);
    Random rand = new Random(); 
    int int1 = 1;
    int int2 = 1;
    int int3 = 1;
    
    
    
  //  Wall w ; 
    
    //create the player here
    //Player o = new Player(20,20);
    //Player i = new Player(0,20);
    
    
    ArrayList<Wall> PainAndSuffering = new ArrayList();
    
    PainAndSuffering.add( new Wall(9,20));
    PainAndSuffering.add( new Wall(11,20));
    PainAndSuffering.add( new Wall(9,19));
    PainAndSuffering.add( new Wall(11,19));
    PainAndSuffering.add( new Wall(9,18));
    PainAndSuffering.add( new Wall(11,18));
    PainAndSuffering.add( new Wall(9,17));
    PainAndSuffering.add( new Wall(11,17));
    PainAndSuffering.add( new Wall(9,16));
    PainAndSuffering.add( new Wall(11,16));
    PainAndSuffering.add( new Wall(9,15));
    PainAndSuffering.add( new Wall(11,15));
    PainAndSuffering.add( new Wall(9,14));
    PainAndSuffering.add( new Wall(11,14));
    
    PainAndSuffering.add( new Wall(9,13));
    PainAndSuffering.add( new Wall(11,13));
    PainAndSuffering.add( new Wall(9,12));
    PainAndSuffering.add( new Wall(11,12));
    PainAndSuffering.add( new Wall(9,11));
    PainAndSuffering.add( new Wall(11,11));
    PainAndSuffering.add( new Wall(9,10));
    PainAndSuffering.add( new Wall(11,10));
    PainAndSuffering.add( new Wall(9,9));
    PainAndSuffering.add( new Wall(11,9));
    PainAndSuffering.add( new Wall(9,8));
    PainAndSuffering.add( new Wall(11,8));
    PainAndSuffering.add( new Wall(9,7));
    PainAndSuffering.add( new Wall(11,7));
    PainAndSuffering.add( new Wall(9,6));
    PainAndSuffering.add( new Wall(11,6));
    PainAndSuffering.add( new Wall(9,5));
    PainAndSuffering.add( new Wall(11,5));
    
    

    // create the enemy here 
    while (true){
      //if(e.gety() < p.gety
    
    
    // remember to use separate nested for loops to create and display the map 
    // create the map here 
    char [][]map = new char[21][21];
    for (int row=0; row<21;row++){
      for (int col = 0; col <21;col++){
        map[row][col]='.';
      }
    }
    int rand_int1 = 1;
    rand_int1 = rand.nextInt(11);
    //player
    for (Wall w: PainAndSuffering){
      map[w.gety()][w.getx()] = w.getSymbol();
    }
    
    if (int3 >= 2){
      map[d.gety()][d.getx()] = d.getSymbol();
    }
    else{
      map[p.gety()][p.getx()] = p.getSymbol();
      map[e.gety()][e.getx()] = e.getSymbol();
    }
    
    
    
    System.out.println("                       N");
    System.out.println("                      W+E");
    System.out.println("_____________________  S");
    for (int row=0; row<21;row++){
      for (int col = 0; col <21;col++){
        System.out.print(map[row][col]);
      
      }
        System.out.println("|");
    
    }
    System.out.println("---------------------");
    String way = bot.nextLine().toLowerCase();
    if (int1 == 1){
      System.out.println("Where to?");
    
      
    }
    int int4 = int3 - 1;
    if (int3 > 1){
      System.out.println("You is ded "+int4+" tims");
      int3 = int3 + 1;
    }
    else if (way.contains("n")){
      if (p.gety()==e.gety() && p.getx()==e.getx()){
        System.out.println("You was killed");
        int3 = int3 + 1;
      } else if (rand_int1 == 1){
          System.out.println("You tripped and ded");
          int3 = int3 + 1;
      } else{
          p.moveup();
          d.moveup();
          int2 = 1;
          
      }
    }
    else if (way.contains("s")){
      if (p.gety()==e.gety() && p.getx()==e.getx()){
        System.out.println("You was killed");
        int3 = int3 + 1;
      }
      else if (rand_int1 == 1){
        System.out.println("You tripped and ded");
        int3 = int3 + 1;
      }
      else{
        p.movedown();
        d.movedown();
        int2 = 1;
      }
    } else if (way.contains("w")){
      if (p.gety()==e.gety() && p.getx()==e.getx()){
        System.out.println("You was killed");
        int3 = int3 + 1;
      } else if (rand_int1 == 1){
        System.out.println("You tripped and ded");
        int3 = int3 + 1;
      } else{
        p.moveleft();
        d.moveleft();
        int2 = 1;
      }
    } else if (way.contains("e")){
      if (p.gety()==e.gety() && p.getx()==e.getx()){
        System.out.println("You was killed");
        int3 = int3 + 1;
      }
      else if (rand_int1 == 1){
        System.out.println("You tripped and ded");
        int3 = int3 + 1;
      }
      else{
      p.moveright();
      d.moveright();
      int2 = 1;
    }
    if(e.getx()<p.getx()){
      e.moveright();
    }
    else if(e.getx()>p.getx()){
      e.moveleft();
    }
    if(e.gety()>p.gety()){
      e.moveup();
    }
    else if(e.gety()<p.gety()){
      e.movedown();
    }
    if (int2 == 1){
      System.out.println("Where to?");
    int2 = 1+rand_int1;
    int1 = 1+rand_int1;
    //p.moveup();
    //i.moveup();
    //o.moveup();
    //o.moveleft();
    //i.moveright();
    //e.movedown();
    // set the player and the enemy coordinates here 
    //e.move(p);
    
    // draw the map here 
    
    
    }
    
    
    
  }
  
  
  
}
}
}
//create the Player class and Enemy class in separate files i.e. Player.java and Enemy.java 
?