Monster Hotel

Monster Hotel
Play online


Monster Hotel

Overview

All of the monsters in Monsterland stopped by the local bar for a few drinks after a hard day of monster work.
Since drinking and driving is not permissible in Monsterland, the monsters need to find their way to the Monster Hotel to stay the night.  As the owner of Monster Hotel, you need to help the drunken monsters find their way to your establishment.

All monsters coming out of the bar are boogey men. Use your powers to transform the monsters to make their way to the Monster Hotel.

Wolf Man – Can dig through ground
Vampire – Allows the monster to land softly from a long drop
Frankie – Blocks other monsters from proceeding

Post Mortem

The game uses the same basic mechanics as the  Lemmings game that I first played on the SNES.  I remember Nintendo heavily promoting the game at the time, as it was featured on the cover of Nintendo Power.  In 48 hours, I knew I couldn’t implement all of the different Lemming abilities.  Therefore, I just picked three of the ones that I remembered.  Those were the digger, the floater, and the blocker.

For this game I used Tiled for generating an XML file containing the positions of the blocks, as well as the entry and exit positions.  The TMX file has to be renamed to TXT and placed in the Resources folder to be able to assign it to a TextAsset which is used by my UnityHelper XmlReader script.  Then the Prefabs are assigned to the script, which does the job of instantiating the Prefab objects at the correct positions.

I created an object which spawns the units at regular intervals.  The units will keep walking in a straight line until they collide with a wall.  I used a capsule collider for the unit, and I set the local Z velocity to a constant value on every frame.  When the unit collided with a object with the wall tag, I would rotate the unit by 180 degrees, which would make the unit walk in the other direction since the local Z is now pointing in the opposite direction.  Unfortunately, it would also detect a collision when the capsule collider touched the ground.  To fix this, I added a box collider in front of the unit which does not touch the ground and fires a trigger when it hits something with the wall tag.  By using a trigger, I ensure that my box does not react to the world physics.  I also added a similar trigger event so that the units reverse direction when bumping into each other.  Otherwise, the units would start stacking on top of each other.  Ideally, I would have the units pass through each other, but that problem would be too difficult to solve under the time constraints.  To keep the units pinned on the Z plane, I set the rigid body constraints on the Z position.

Another problem arose when the trigger box hits two wall blocks at the same time.  This would change the direction of the character, and then immediately change it back to the original direction.  To fix this, I added a small amount of delay to the trigger state so it would only fire on one trigger events.
The digger simply stops and starts digging a hole below his current position.  I determined which block to remove by shooting a ray downward from the unit’s position.  However, this really didn’t create a hole big enough for the units to fall through.  I used the position of the block removed and casted a ray to the left and right of that position, and destroyed the adjacent blocks as well.

The floater unit prevents the unit from dying after a long fall.  I added another collision event which compared the force returned from a collision, and if it is greater than a certain value (force of falling more than three units down) then it would destroy the unit.  When I was testing this, I never noticed the units dying, so it seemed like I was losing units for no reason.  For that reason, I spawned a particle effect where the unit was destroyed.  I just used a standard particle effect, but I wish I could have made a goopy style splatter.  To obtain the floating effect, I simply increased the drag value on the unit’s rigid body.
The blocker was fairly easy to implement.  When that ability is activated, I just increased the mass of the unit so that other units can not push it.  I also set the movement to the standing state, similar to the digger, so that the unit stays stationary.

I increased the available ability types by one for each stage.  That way, the player is not presented with all of the abilities at once.  Using the new ability type is essential for completing the current stage.  If I had more time, I would have liked to had more levels, and levels that would require using a combination of abilities to complete.

I saved the modeling and graphics for last.  In some of my past entries I would spend too much time on the modeling, so this would force me to do it quickly.  Since this is a monster theme, I decided to use a different monster for each ability.  The default creature is the boogeyman, since I think of the boogeyman as being any type of creature.  The Wolf Man is a digger because I think of canine type creatures as diggers.  I made the floater a vampire, since bat type creatures can fly.  I made the blocker a Frankenstein (shortened to “Frankie”) since he is big and immovable.  I wish I could have made a morphing effect when transitioning between abilities.

I used Blender for making the character models. I created a simple half outline in Gimp, and then I used that outline to form my models using loop cuts, resizing, and translating vertex positions.  I created a simple six bone armature and created a simple walk animation in the dope sheet action editor.  I then unwrapped the mesh using the “from view” option which makes painting the texture model much easier (although there is more stretching around the sides).  I exported the layout in the UV editor and painted the texture in Gimp.  I did mess up once by not separating the front and back layouts, so my creature had eyes in the back of its head.  Separating the back layout wasn’t too difficult, so I just had to draw the back side of the creature.

The boogeyman that I designed is just a simple imp type creature.  I used the same mesh for the wolf man, but I gave him pointy ears and I elongated his snout.  I tried giving the vampire wings, and used white face with a black rope with red trim.  I had “the master” from Manos: The Hands of Fate” in mind.  Frankie was given a blocky head and body, which was done by modifying the mesh.  I wasn’t going to spend the time modeling bolts into the side of his neck.

I modified the animations slightly for the monsters.  The vampire flaps his wings.  Frankie holds out his arms and twists his head in a similar fashion to the blocker in Lemmings.

I updated my GarageBand software to the latest version earlier in the week, and I used it on my Mac laptop for composing the music.  I used a B minor signature for composing the music.  I used some organs which sounded creepy and kept modifying the notes until it sounded okay.  I made another similar track which was a little slower for the title screen.

I recorded my own voice making howling, “blah”, and grunting sounds for each of the monster types.  I lowered the pitch and added echo effects to make the sound effects seem more creepy.

Overall, I am happy with what I was able to accomplish in two days.  This entry definitely feels more “gamey” than my previous Ludum Dare entries.  The biggest weakness of this entry is probably the lack of levels, since I only have three and ran out of time to make more.  I will probably make a short trailer and throw it up on Steam Greenlight to see what sort of response it gets.

 

Released

Model Rendering in Game

Today, I exported my Blender helmet model to AutoDesk FBX format to try to get it to render in my game in real time.  The first problem I encountered was that it could not detect my texture.  This was because I was borrowing the texture from the “boot” folder when I did the mapping in Blender.  Therefore, I had to move the texture I  was using in Blender to a “texture” folder at the same level as my exported FBX model.

After loading the FBX model and texture as content items in my project, I created a new Screen subclass which is the 3D display.  Theoretically, this could run concurrently with the existing 2D game screen.  For now, I just created a new main menu item for the 3D game screen.  Using an example from Microsoft, I created a new method in the 3D game screen which renders the model(s).  The model is first loaded in my main game class, then the new model draw method takes the list of models as a parameter.  It also takes the aspect ratio as a parameter, since that is what the example does, but I may remove it or make it a constant later if it does not change.

screen073

Finally, after I finished setting up my model and I ran the program and all I saw was the blue clear color.  Then I noticed a small speck which I first thought was a piece of dust.  This at least let me know that something was rendering, because removing the model drawing code would also remove the black speck.  I think this was because the example code has the camera Z position at 5000f, which I guess was for a really huge model.  Next I tried removing the lines of code in the effects loop for World, View, and Projection one at a time.  By removing all three, I was able to see a rendering of what looks to be the top side of the helmet.  After thinking about it, this makes since because in Blender the Z axis is up, but in XNA the Y axis is up.  Another possible problem is that some of the transformations in the example code look for a parent bone, which I don’t currently have defined for my helmet.

I remembered having to change the export coordinates when exporting my building objects for TetraCity to OBJ format, so that it makes Y up instead of Z.  In the FBX exporter for Blender 2.6, this option is found in the lower left corner of the file save menu of the exporter.  This is really easy to miss if you’re not looking for it, because previous versions of Blender had most options in a popup dialog box.  The fix is made by setting “Forward” to “-Y Forward” and “Up” to “Z Up”.  Selecting “-Y Forward” should automatically set “Z Up”, which is faster because “Z Up” can not be selected with “-Z Forward” selected.  There are also two options for XNA.  I don’t know what these do, but I went ahead and selected them.  Select “XNA Strict Options” should automatically select the other XNA option.  Even with selecting Z Up option, my model was still displaying as if Y is on the horizontal plane.  Either the exporter is broken or my model is not getting updated in the XNA project.  I tried exporting my model to a new filename, and I imported the new model but I still got the same results.  Therefore, the exporter does not appear to be translating the coordinates appropriately for some reason.  Alternatively, I could fix the rotation in code, but that is just one more additional thing to have to do.

screen074

So to get an object moving around the screen, I basically had to go back to step one from three months ago.  I added my helmet object, and added velocity controls to move it up and down.  Once I figure out how to get my current game coordinates to map to 3D space, then I think most of my game world coordinates should translate over with little effort (hopefully).  There also appears to be some tearing with the polygons, which I think may be due to the Z ordering of the faces, because some of the lower polygons will appear above the higher ones.

screen075

Model Animation

http://www.youtube.com/watch?v=0qEkqUv6CRQ

New model created using keyframes which generates the animation images.  Now using a 20 frame walk cycle.  FPS meter drops slightly due to XSplit recording software.

Engine

Spent some time streamlining the game engine.  There were a few glitches when moving from one room to another, so almost all of those should be resolved now.  It can be really tricky detecting collision with a block in an adjacent map array, while keeping the map offset straight and moving the player to the next map at the appropriate time.  I was thinking that it may be easier to just keep a single array which holds the blocks of the current screen, and then copying the blocks from the room arrays to the current screen array.  However, I think the method I have now seems to work, but it is a little bit of a pain to keep track of which room the player, projectiles, and enemies are located, especially when they cross the room boundary.  When the projectiles and enemies cross the room boundary, they will need to be removed from their current room and added to the next room.

Modeling with Animation

I found another tutorial on YouTube for making a model with animation in Blender.  Well, the first 12 minutes are just making the armature, which I learned how to do last week.  Then it shows how to create the keyframes and animation, which is really easy once you know how to do it.  I think before I didn’t have the record button pressed, along with dragging the keyframe, which caused my first model attempt to not animate.  With those settings enabled, I was able to get my simple model to run.

Pressing the play button makes my model run.  There is another animation button which renders each frame, but it doesn’t display if or where the images for each frame are saved.  After some searching, I found the output directory hidden by scrolling to the bottom of the right pane.  I set that to my project directory in a folder named anim, and then pressed the animation button which generated a png for each frame.  The first set of files didn’t have transparency, so I had to go back and select the RGBA option next to the PNG option.  It actually just displays as a second RGB button, probably due to limited button space.

 

The next problem is that the image is way too big (960×540) and out of proportion to be used as a character sprite.  I did some searching on the Gimp forums and found that multiple files can be cropped and modified at once by using Open as Layers.  This way, I was able to crop, scale, and resize the image to 48×96 which is the size of two tiles in the game.

.

Now the problem is getting each layer back out as an image.  Unfortunately, I didn’t find any information on how to do this in Gimp.  I started by copying each layer and then pasting as a new image, and saving after each paste.  However, this got really old after doing it about 8 times out of 20 frames.

Did some searching a found a Python script that someone wrote to save all of the layers in an image to PNG.  This worked (after dealing with file extensions and figuring out where to put the plugin), but it saved the file with the .png extension, even though the layer name already has .png, which resulted in the files coming out at image.png.png.  I just had to modify one line to not add the .png extension to the end.

Now that I had the images, I imported all of them into my game project’s Content area.  It may be more efficient to make a sprite sheet, but I doubt it will make that much of a performance enhancement.  It’s something I can look into later.  I added all of the images to my texture array, and modified the walk animation of my character to use 20 frames instead of 3.