The LCD display is the next step. LCD stands for Liquid Crystal Display. LCDs consist of segments of liquid crystal. Each segment is a circuit which can have electricity applied to it. When electricity is applied, the crystal becomes opaque therefore giving you the ability to turn on or off individual segments. Undoubtably, some of you readers are using a LCD monitor of some sort to read this. Those displays have the crystals set up in a nice grid pattern and form nice square dots. When I think of LCDs, I think of the displays used on digital watches and alarm clocks. The crystal shaped segments in those are formed into a seven segment eight. Why? When you look at the seven segments that form an eight, you can easily see how turning off some of those segments would allow you to create any other numerical digit.
To simulate a LCD display then, all we need is a crystal that can be turned on and off, then assemble that crystal into a display and create numbers by turning on and off individual segments. Or we could take an easy approach and just have the on and off crystal images and combine them into an eleven key-frame movie that happens to have these images combined to form the numbers. You can probably guess which approach I took. Well, sort of. I had used a LCD display in another game so in reality I just copied the movie clip from that movie. In fact, that movie clip also supports the negative sign so there are 12 key-frames.
The code for this movie feature a setNumber(n) function which makes the movie goto and stop at the appropriate frame. In addition to the ten numerical values, -2 is used to get an empty number and -1 is used for the negative sign. An additional getNumber function returns the current value of the display.
In addition to the number display, I want a leading one and arrows for left and right shifting indication. Both of these were created the same way. I have a movie that has an on state and an off state. Four functions are available for controlling these movies. The setOn() function turns on the crystal, setOff turns it off, setState(b) lets you specify on (true) or off (false) and isOn() returns true if the crystal is on or false if it is not on.
Obviously, this LCD system was going to be attached to the Door Group movie clip. Two layers were added to this clip. First, I added a layer that simply consisted of a dark square for a background for the display. Over this I added the 4 pieces of the LCD. These consisted of the left arrow, the one digit, the number, and the right arrow. A simple function needed to be written to control this. This function simply calls the LCD objects and sets them to the appropriate values. The only slightly tricky aspect of this is the need to break the room number into high and low digits.
It goes without saying that before the LCD over the block of doors can display anything useful, it has to be called. This is done from the main loop. In fact, it can be done immediately, even though the two arrows aren’t used yet. To test the lcd, including the arrows, the following code was added to the main loop.
The code sets the left and right flags based on whether the room is odd or even. Once we have confirmed that the arrows do work, we can replace the boolean equation with false and will have an LCD that works with the standard mode. When we actually are ready to have proper arrows, those can be set within the conditional block by simply changing the leftFlag or rightFlag variable to true. Before we can worry about which light to turn on, we first need to implement rotation.
Previous | Making Deadly Doors Contents | Page 7 of 10 | Deadly Doors | Next |
About -
Privacy Policy -
Contact -
Links -
FAQ
Copyright © 2005-2006 Blazing Games Inc. All Rights Reserved.