repl.it
@AZRIELGIESWEIN/

Super 2D Array Game with Java Skill Building-1

Java

No description

fork
loading
Files
  • Main.java
  • Chest.java
  • comments.java
  • Ded.java
  • Enemy.java
  • Player.java
  • Wallc.java
  • WallC.java
  • WallH.java
  • WallV.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
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 = 0;
    int int3 = 1;
    
    
    
  //  Wall w ; 
    
    //create the player here
    //Player o = new Player(20,20);
    //Player i = new Player(0,20);
    
    
    ArrayList<WallH> PainAndSuffering = new ArrayList();
    
    PainAndSuffering.add( new WallH(9,20));
    PainAndSuffering.add( new WallH(11,20));
    PainAndSuffering.add( new WallH(9,19));
    PainAndSuffering.add( new WallH(11,19));
    PainAndSuffering.add( new WallH(9,18));
    PainAndSuffering.add( new WallH(11,18));
    PainAndSuffering.add( new WallH(9,17));
    PainAndSuffering.add( new WallH(11,17));
    PainAndSuffering.add( new WallH(9,16));
    PainAndSuffering.add( new WallH(11,16));
    PainAndSuffering.add( new WallH(9,15));
    PainAndSuffering.add( new WallH(11,15));
    PainAndSuffering.add( new WallH(9,14));
    PainAndSuffering.add( new WallH(11,14));
    
    PainAndSuffering.add( new WallH(9,13));
    PainAndSuffering.add( new WallH(11,13));
    PainAndSuffering.add( new WallH(9,12));
    PainAndSuffering.add( new WallH(11,12));
    PainAndSuffering.add( new WallH(9,11));
    PainAndSuffering.add( new WallH(11,11));
    PainAndSuffering.add( new WallH(9,10));
    PainAndSuffering.add( new WallH(11,10));
    PainAndSuffering.add( new WallH(9,9));
    PainAndSuffering.add( new WallH(11,9));
    PainAndSuffering.add( new WallH(9,8));
    PainAndSuffering.add( new WallH(11,8));
    PainAndSuffering.add( new WallH(9,7));
    PainAndSuffering.add( new WallH(11,7));
    PainAndSuffering.add( new WallH(9,6));
    PainAndSuffering.add( new WallH(11,6));
    PainAndSuffering.add( new WallH(9,5));
    PainAndSuffering.add( new WallH(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);
    int rand_int2 = 1;
    rand_int2 = rand.nextInt(3);
    //player
  
    for (WallH w: PainAndSuffering){
      map[w.gety()][w.getx()] = w.getSymbol();
    }
    
    if (int3 >= 2){
      map[d.gety()][d.getx()] = d.getSymbol();
      int2 = 0;
    }
    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?");
    }
    if (int2 >= 1){
      System.out.println("Where to?");
    int2 = 1+rand_int1;
    }
    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;
        for (WallH w: PainAndSuffering){
          if (p.gety()==w.gety() && p.getx()==w.getx()){
            p.movedown();
            d.movedown();
            if (rand_int2 == 3){
              System.out.println("You slammed head in wall,");
              System.out.println("wow you are really stupid.");
              int3 = int3 + 1;
            }
            else{
              System.out.println("There is a wall there, stupid.");
        }}}
          
        
      
      }
        }
    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;
        for (WallH w: PainAndSuffering){
          if (p.gety()==w.gety() && p.getx()==w.getx()){
            p.moveup();
            d.moveup();
            if (rand_int2 == 3){
              System.out.println("You slammed head in wall,");
              System.out.println("wow you are really stupid.");
              int3 = int3 + 1;
            }
            else{
              System.out.println("There is a wall there, stupid.");
        }}}
        
        
        }
    
    }
    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;
          for (WallH w: PainAndSuffering){
            if (p.gety()==w.gety() && p.getx()==w.getx()){
              p.moveright();
              d.moveright();
              if (rand_int2 == 3){
                System.out.println("You slammed head in wall,");
                System.out.println("wow you are really stupid.");
                int3 = int3 + 1;
              }
              else{
              System.out.println("There is a wall there, stupid.");
          }}}
        
          
          }
          
      
    } 
    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;
        for (WallH w: PainAndSuffering){
          if (p.gety()==w.gety() && p.getx()==w.getx()){
            p.moveleft();
            d.moveleft();
            if (rand_int2 == 3){
              System.out.println("You slammed head in wall,");
              System.out.println("wow you are really stupid.");
              int3 = int3 + 1;
            }
            else{
              System.out.println("There is a wall there, stupid.");
            
        }}}
      }
    }
        if(e.getx()<p.getx()){
          e.moveright();
          for (WallH w: PainAndSuffering){
            if (e.gety()==w.gety() && e.getx()==w.getx()){
              e.moveleft();
              if (rand_int2 == 3){
                System.out.println("The Enemy got biggie mad");
                int3 = int3 + 1;
          }}}
            
        }
        else if(e.getx()>p.getx()){
          e.moveleft();
          for (WallH w: PainAndSuffering){
            if (e.gety()==w.gety() && e.getx()==w.getx()){
              e.moveright();
              if (rand_int2 == 3){
                System.out.println("The Enemy got biggie mad");
                int3 = int3 + 1;
          }}}
        }
        if(e.gety()>p.gety()){
          e.moveup();
          for (WallH w: PainAndSuffering){
            if (e.gety()==w.gety() && e.getx()==w.getx()){
              e.movedown();
              if (rand_int2 == 3){
                System.out.println("The Enemy got biggie mad");
                int3 = int3 + 1;
          }}}
        }
        else if(e.gety()<p.gety()){
          e.movedown();
          for (WallH w: PainAndSuffering){
            if (e.gety()==w.gety() && e.getx()==w.getx()){
              e.moveup();
              if (rand_int2 == 3){
                System.out.println("The Enemy got biggie mad");
                int3 = int3 + 1;
          }}}
        }
        
      
    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 
?