New rooms

This week I was busy adding new room into the game. First one was circular with nothing special in it. But that room serves as a base for couple other rooms:

Fountain is currently just a decorative element. Characters can pass through the square it occupies and it has no functionality at all in the game. Eventually players will probably be able to drink from it or drop items into it.


Second new room is a shrine. It shares the layout with fountain, but has an altar and couple of candles in it. Like fountain, the shrine is currently just a decorative feature. Future of it is pretty unclear still. The most obvious usages would be praying and sacrificing, but maybe I can come up with something more unique still.temple

There needs to be a place to store all the spellbooks and such. A library is a perfect place for that. Unlike shrine and fountain, the shelves are actually blocking players movement. I have an idea of special monster that would occupy libraries (no, not an orangutan though), but they need some fleshing out and some new code.


The last new room is graveyard. The layout is similar to library, but instead of shelves, there are graves. And graves actually have a function in game. With correct implements, it is possible to dig them up and reveal what have been buried in them. Some of the things are good, while other are not good at all.


The nifty thing about the new rooms is that they are built on top of old room generators and parametrized. Shrines and fountains are generated by the same class, but with different settings. Libraries and graveyards are done in the same way:

(defclass LibraryRoomGenerator [SquareRoomGenerator]
  "generator for library rooms"
  [[--init-- (fn [self floor-tile corridor-tile walls decos rate feature-creator level-types]
               "default constructor"
               (-> (super)
                   (.--init-- floor-tile nil corridor-tile level-types))
               (setv self.walls walls)
               (setv self.decos decos)
               (setv self.rate rate)
               (setv self.feature-creator feature-creator)
   [generate-room (fn [self section]
                    (-> (super)
                        (.generate-room section))                    
                    (ap-each self.rows 
                             (when (<= (.randint random 1 100) self.rate)
                               (when self.walls 
                                 (section-wall section it (.choice random self.walls) "wall"))
                               (when self.decos
                                 (section-ornamentation section it (.choice random self.decos)))
                               (when self.feature-creator
                                 (self.feature-creator (:level section) 
                                                       (section-to-map section it))))))]])

First routines from SquareRoomGenerator create an empty room. After that LibraryRoomGenerator takes over and starts placing tiles (tomb stones in this case) on locations listed in rows collection. This collection was filled by SquareRoomGenerator, in order to make it easier to build rows of something in room in a way that there is walking space in between them. The last finishing touch is to call feature-creator if it has been supplied. In case of graveyard, it is an function that marks the square as a grave randomly populates it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s