Guest User

Untitled

a guest
May 28th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public void randomLevel() {
  2. Random rand = new Random(System.currentTimeMillis());
  3. numitems = 0;
  4. for(int i=0;i<map.length;i++) {
  5. for(int j=0;j<map.length;j++) {
  6. int val = rand.nextInt(21);
  7. if(val=<2 && numitems >40) //For very few tiles, draw a floor with a Poison
  8. map[i][j] = new Floor(i,j, new Poison());
  9. if(val<4 && val>2) //for 20% of tiles, draw a wall
  10. map[i][j] = new Wall(i,j);
  11. if(val>=4 && val<=17) //for most tiles, draw a floor without an item
  12. map[i][j] = new Floor(i,j,null);
  13. if(val>17 && val<20) { //For several tiles, draw a floor with a Gem
  14. map[i][j] = new Floor(i,j, new Gem());
  15. numitems++;
  16. }
  17. if(val==20) { //For a few tiles, draw a floor with a Diamond
  18. map[i][j] = new Floor(i,j, new Diamond());
  19. numitems++;
  20. }
  21.  
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment