Results 1 to 5 of 5
  1. #1
    totalspelnerd is offline Member
    Join Date
    Mar 2012
    Location
    Sweden
    Posts
    83
    Rep Power
    0

    Default [How?] Random dungeon generator (like Binding of Isaac)

    I'm programming a game like Binding of Isaac and right now I'm stuck at creating a random dungeon generator. I've looked through Google pretty much all day and I just can't find anything that could work like I want to. I've tried the A* path finding alg but I didn't like the results. Right now I barely have any code for the generator, just an ID array that contains Zeros. If it is by any help I want the spawn room to be a 2 in my array, the dungeon halls to be 1 and boss room to be 3. The array is 11 in width and 7 in height right now.

    Thanks for spending time on me :D

  2. #2
    totalspelnerd is offline Member
    Join Date
    Mar 2012
    Location
    Sweden
    Posts
    83
    Rep Power
    0

    Default Re: [How?] Random dungeon generator (like Binding of Isaac)

    I've fixed this now. Can't edit my post for some reason though.

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: [How?] Random dungeon generator (like Binding of Isaac)

    If you tell us how you solved it, it might help someone who finds your question in a search.
    Get in the habit of using standard Java naming conventions!

  4. #4
    totalspelnerd is offline Member
    Join Date
    Mar 2012
    Location
    Sweden
    Posts
    83
    Rep Power
    0

    Default Re: [How?] Random dungeon generator (like Binding of Isaac)

    sorry didn't see the comment. Here is the code explained:

    Java Code:
    //generate a random spawn position
    int x = rand.nextInt(width);
    int y = rand.nextInt(height);
    ID[x + y * width] = 2;
    
    
    //generating rooms
    for (int i = 0; i < 14; i++) {
    	boolean done = false;
    	while (!done) {
    
    		//this is a method that generates two random positions and put them into a Point.
    		// Can be made differently
    		Point p = generateNewRoom();
    
    		//Here I check if the room at the given point is occupied.
    		//if it is it won't continue and restart the while loop
    		if (getRoomAt(p.x, p.y) == 0) {
    
    			/*
    			getRoomsBeside(x,y) returns the amount of rooms there is beside the given point.
    			doesn't check diagonal. since I don't want room with 4 adjacent rooms it doesn't
    			continue if the method returns 3 or over. Same if there is no room beside.
    */
    			if (getRoomsBeside(p.x, p.y) < 3 && getRoomsBeside(p.x, p.y) > 0) {
    				ID[p.x + p.y * width] = 1;
    				done = true;
    			}
    		}
    	}
    }
    If you need more explanation just ask :D

  5. #5
    Join Date
    Jun 2013
    Location
    Sheffield
    Posts
    4
    Rep Power
    0

    Default Re: [How?] Random dungeon generator (like Binding of Isaac)

    This would be very useful for my game in the future, so some explanation would be nice. Thank you!
    Please PM/message me when you have!
    Last edited by CadeLegallow; 06-10-2013 at 06:46 PM.

Similar Threads

  1. Random number generator
    By adjit in forum New To Java
    Replies: 9
    Last Post: 03-05-2012, 04:09 PM
  2. Random number generator
    By zerwik in forum New To Java
    Replies: 3
    Last Post: 12-26-2010, 12:10 PM
  3. Random Generator
    By Learning Java in forum New To Java
    Replies: 9
    Last Post: 05-31-2010, 08:15 PM
  4. Random Numbers generator
    By pinkdreammsss in forum Java Applets
    Replies: 10
    Last Post: 04-08-2010, 03:38 AM
  5. Random Generator
    By padutch2 in forum New To Java
    Replies: 1
    Last Post: 12-03-2007, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •