A map generatore for the current corridors contest.
By : GiantPeach
mapgen.php - simple form to submit 5 parms to map generator: min room width, max room width, min room length, max room lenght, and number of rooms. All should be integers 1 - 99 (very little error checking, will break if parms are bad).
showmap.php - main code, creates room objects and steps through map to determine if blocks are within room boundaries. If a block falls in the boundaries of one of the rooms it is marked as a "1". Output from showmap.php is a graphical representation of the map, along with three textareas with the serialized array data, php statements to populate the array, and php statements to populate only the room blocks. In all cases, the first array index is the row (top to bottom) and the second index is the column (left to right). Both are 0 - 99.
room.php - room class definition for use with above. Constructor picks random "center point" for room, then randomly sizes the room and determines top/bottom/left/right boundaries. The in_room method accepts row, column coordinates and returns true if that cell is within the room's boundaries.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.