The first step to the game was to come up with the map. The original Hunt the Wumpus was based off of a squashed dodecahedron but had the location of the Wumpus and traps randomly located in the map. It also had the Wumpus moving. As we do not have JavaScript, this is not really possible in our simplified version of the game so to get around the lack of randomness and movement, the traps and Webbus have been hard coded into the map. To reduce the amount of art that needs to be produced, I decided to only have 4 different background images for the locations, in addition to the special pages for the traps. The image to use is color coded.
Once the map was worked out the next task was to work out the navigation. I wanted to keep things simple and use links, so in the CSS file for the game I set up some rules for making the links look like buttons. More details on how these work can be found in section 3.10, but the “button” code is as follows:
We also want to set up some general layout rules. The biggest issue that we have to worry about is that there are different resolutions of displays, and even within the different resolutions, people don’t need to have the browser take up the full screen (I tend to have it half a screen myself). This means that there will be a lot of empty space. One solution would be to have different layouts based on the resolution, which is something we will be covering in later chapters. Another solution, which is my go-to solution, is to have borders around the content that scale so that the contents is in the middle of the display. I do this by having an outer wrap that has a color and aligns everything to be centered. Inside this, there is the content wrap layer which holds the game contents with a different background color.
With this done, we can put together a typical room page. All the non-trap room pages will essentially be the same with the difference being the image used and the locations that the buttons lead to. Here is the body of the first room.
You will notice that all the arrow links to this room lead to a single page. This is the losing page used for when the player has missed. In the three rooms where there is a successful shot, we link to a different page. The downside to this approach is that the player can cheat and take a look at the link, but it does save us 18 pages so I will assume that my players are playing the game honestly instead of having links to arrow shots for each of the 20 room.
The Slime and Webbus rooms simply lead to the end of the game so are trivial to put together. This leaves us with the teleportation trap. This turns out to be very simple as you simply need to display a teleportation image and a single button that takes the player to the room that the teleporter takes the player to.
Overall, not that difficult of a project. The source code to this is on the git repository.
A cheat sheet covering the basics of CSS.
A brief look at what CSS is and how it came to be.
A look at the three different ways to add style to your document.
Setting the style for different types of elements.
An easy way of having multiple styles on the same element type and across different elements.
The use of named colors, the RGB color model, and creating RGB colors.
Using hexadecimal color codes and other color models.
Controlling what text looks like.
The box model controls how elements are positioned within their layout box.
Anchor element states and turning a link into a button.
A total conversion of Hunt the Webbus with a Christmas Theme.
Lists can have style applied to their layout, placement, and bullet.
Tables have a grid as well as rows and columns that can be controlled.
The project for this chapter is a variation of a classic text game
My solution for the Webbus project
Converting the Webbus game into a Christmas game.