Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void randomLevel() {
- Random rand = new Random(System.currentTimeMillis());
- numitems = 0;
- for(int i=0;i<map.length;i++) {
- for(int j=0;j<map.length;j++) {
- int val = rand.nextInt(21);
- if(val=<2 && numitems >40) //For very few tiles, draw a floor with a Poison
- map[i][j] = new Floor(i,j, new Poison());
- if(val<4 && val>2) //for 20% of tiles, draw a wall
- map[i][j] = new Wall(i,j);
- if(val>=4 && val<=17) //for most tiles, draw a floor without an item
- map[i][j] = new Floor(i,j,null);
- if(val>17 && val<20) { //For several tiles, draw a floor with a Gem
- map[i][j] = new Floor(i,j, new Gem());
- numitems++;
- }
- if(val==20) { //For a few tiles, draw a floor with a Diamond
- map[i][j] = new Floor(i,j, new Diamond());
- numitems++;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment