Created
July 17, 2015 16:08
-
-
Save matthewd673/4eb001148dd099b00da7 to your computer and use it in GitHub Desktop.
A simple dungeon generator for MiniLD 61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[][] rooms = new int[100][100]; | |
public static void generate() | |
{ | |
Random rndgen = new Random(); | |
for(int i = 0; i <= 99; i++) | |
{ | |
for(int j = 0; j <= 99; j++) | |
{ | |
int roomtrue = rndgen.nextInt(5); | |
rooms[i][j] = roomtrue; | |
} | |
} | |
} | |
public void paint(Graphics g) | |
{ | |
generate(); | |
for(int i = 0; i <= 99; i++) | |
{ | |
for(int j = 0; j <= 99; j++) | |
{ | |
g.drawRect(i * 20, j * 20, 20, 20); | |
if(GenerateDungeon.rooms[i][j] == 1) | |
{ | |
Random roomgen = new Random(); | |
int roomwidth = roomgen.nextInt(12) + 5; | |
int roomheight = roomgen.nextInt(12) + 5; | |
g.setColor(new Color(255, 255, 255)); | |
g.fillRect(i * 9, j * 9, roomwidth, roomheight); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment