Subject: Fun with dungeon generation in qbasic Date: Sat, 16 Feb 2002 23:00:31 GMT From: withheld@withheld.withheld (R. Alan Monroe) Organization: Posted via Supernews, http://www.supernews.com Newsgroups: rec.games.roguelike.development I wondered what it would be like to do a random dungeon by repeatedly placing random sized "L" shaped hallways, each with a random 90 degree orientation, all over the map. Here's the results. This method doesn't guarantee that all areas are reachable. You get a lot of cul-de-sacs, which could be good or bad depending on your game... [fixed width font] ##################################################################### ##################################################################### ################### ####### ######### ####### ########## # ########## ################### ### ### ######## ####### ### ###### # ########## ######## ######### ### ## ### ### ##### ### ###### # ### ###### ######## ## ## # ## ## # # ###### ######## ## # ### # ## ## ### ## # # ##### ## # # # # ##### #### #### # # # # ### ## ## # # ##### ###### # # # ## # # ## # # ##### #### ## # ## # # # # #### # # # ##### ##### # ### # # ### ## # ## ##### ####### ##### ###### # # # # ## # ## ### ###### ##### ## #### # ##### ###### # ##### ##### # ############ ##### # ## # # ########### ########### ##### ##### ############## ########### # ########################## ###### ###### ########################## ############################ ###### ##################################################################### ##################################################################### ##################################################################### ####### #################### ################################ ####### ####### ################ ### ### ############### ########### ####### ####### ############# ## ### ### ## #### # ##### #### ###### ####### ####### ######## ### ## ### ### ## ### ### # #### ## ### ####### ### ####### # # ### ##### # ### # ## ## # # # ## ##### ### # # ## # # ## #### ## # #### # # ## # # ## ## # # #### ## # #### # ## # ## ## # # # # ######## ###### # # ## # ### # # # ######## ####### #### ## # ## ##### ########### #### # ##### ### ### ##### ## ##### ### ## #### # ##### ######## ## ## ###### # ### ## ####### # ### #### # # ##### ######## ##### # ###### # #### ## ####### # ###### ##### ######### ######## ####### ################## ####### # ############ ######### ########################################### ######################### ##################################################################### ##################################################################### ##################################################################### ######################### ##### #################################### ######################## ##### ############# ##################### ####### ############### ##### ######### ### # ################### ##### ### ###### ## # # # ## ## ### # ### ############### ##### # # # ### # # ## ## ###### ##### # # ## ## ### # ####### ###### ##### # ### ## ### # ###### #### ##### ### ## #### # # ## ## ### ##### ####### # # ## # ## ## ## # # ## # ##### #### ## ## # # ## ###### # ### ### ## ## #### ###### # ##### ### #### # ### ###### ##### ##### #### ### ### # ### ###### ### ###### # ###### ###### ##### ##### #### ### ### ## #### ###### ########## # ###### ###### ########### ############ ############## ########### ## ####### ################## ############ ############## ########### ## ####### ##################################################################### RANDOMIZE TIMER DIM a(70, 20) begin: CLEAR CLS FOR l = 1 TO 150 x = INT(RND * 59) + 6 y = INT(RND * 9) + 6 d = INT(RND * 4) a(x, y) = 1 SELECT CASE d CASE 0 FOR i = 1 TO INT(RND * 5) a(x + i, y) = 1 a(x, y - i) = 1 NEXT i CASE 1 FOR i = 1 TO INT(RND * 5) a(x + i, y) = 1 a(x, y + i) = 1 NEXT i CASE 2 FOR i = 1 TO INT(RND * 5) a(x - i, y) = 1 a(x, y - i) = 1 NEXT i CASE 3 FOR i = 1 TO INT(RND * 5) a(x - i, y) = 1 a(x, y + i) = 1 NEXT i END SELECT NEXT l FOR row = 1 TO 19 FOR col = 1 TO 69 IF a(col, row) = 0 THEN PRINT "#"; ELSE PRINT " "; END IF NEXT col PRINT NEXT row WHILE INKEY$ = "" WEND GOTO begin