Cool stuff.
Sorry again for my lack of activity. It feels like days since I have been able to sit at my laptop.
Insha Allah I can upload some code soon as I am quite frankly getting quiet embarrased by my lack of contribution lately.
Indeed I am slowly working on room generation. I will grab your code so I can see how you are handling the drawing, ect to Insha Allah intergrate my code with yours. Your walls and doors look cool. If I can define a room in terms of Width/Height, possibly with a datum (X-Y point of origin) then Insha Allah it will integrate fairly easily with what I am planning.
I would like to have the current room in the center of the screen with an outline of the neighbouring room attached to each door.
For the sake of making a feeling of claustrophobia and suspense, I would like to only render the contents of the current room so the player is never sure what might be in the next room over until they move there.
What I am working on is tree based layout generation.
I have an object class describing the definition of a room and subclasses for room types.
Room types describe dimension and what rooms can be connected to it as a child.
EG:
- Enterance connects with: Hallway, Living room, Office
- Large bedroom connects with: Bathroom
- Small bedroom connects with: NULL.
There are 3 data sets used in generation.
- A tree containing the generated rooms and how they connect
- An array of objects outlining potential room placement objects and what rooms are currently valid to place there
- An array of objects that act as a manifest for what rooms are to be placed in this area.
On start of the function, the function loads a manifest of rooms in the area being generated (An array of room types and number of each room to be placed).
The Root node (An enterance room) is added to the tree, the X-Y location of this room is used to add a set of placement nodes around this first X-Y location with the valid room types to connect to the foyer (Office, Hall and Living-room currently, though these room types have no purpose other then place holders for differnt room sizes and descriptions of what objects may later be spawned inside).
While there are items remaining in tihs manifest, a placement node is selected at random and at its’ list of valid rooms is checked against the manifest array, If a match is found, the room object is spawned as a child node to the room that spawned this placement node. (The room tree can be briefly scanned here to find a room with a neighbouring x-y location capable of connecting to this room type to add extra connections for interconnecting rooms).
As the room is placed, The placement node array is scanned for the neighbouring X-Y positions, if a match is found the allowable connecting room types are added to the node, otherwise a new node is added to this list containing only the allowable connecting room for this type.
The process is repeating until the manifest is exhausted, leaving a tree of room objects to be used for mapping the room layout of the game map.
What I am imagining for this in terms of gameplay…
I would like it if only the room currently occupied by the play is rendered, leaving the player to work of auditory clues for where the enemy is.
- The Enemy AI is to constantly be hunting for the player, randomly moving form location to location
- The player can not see where they are, but they hear movement each time the enemy moves with volume depending on how many rooms away they currently are.
- When the Enemy reaches a closed door, they have a chance of attempting to open it and a subsequent chance of succeess. On this event they generate a sound of bashing on the door
- When the player moves or interacts with an object, they have a chance of drawing the attention of the enemy depending on how many rooms away they are
Gameplay sort of like the old text room-based games where the player will be hunted moving from room to room as they are given written clues about which room the monster is currently in. Replacing the text with a mixture of 2D visuals and sounds.
IE:
- the player is walking around a room examining objects for information.
- They hear the sound of footsteps grow larger than fade, a bashing sound can be heard on a far away door.
- The player decides to risk moving to the next room, they open the door and slip into the connecting hallway.
- Footsteps grow louder so the player opens the next door and rushes inside. Footsteps grow louder but stop.
- Player runs over to a cupboard and interacts with it to hide,
- A loud bashing sound occurs and the door opens, the jinn stepping inside.
- Player remains motionless not agroing the jinn further until it selects a new location and leaves. (Unless they are unlucky and the AI decides to inspect some of the room objects closer.)
In doing this Map_gen function I have learned a heap about the JS array functions like .some() .find() .forEach(), ect. So that is pretty cool. I am no longer using:
For(index=0, index<array.length, index++){ if (condition==true){Do stuff; break;}
instead now:
Array.forEach(Dostuff());
or
if(node.find(XYmatch())!=undefined){ Node.attribute = stuff}