________________________________________________________________________________ tanya laidman cs248 12/7/99 ________________________________________________________________________________ merquest ________________________________________________________________________________ about it: merquest is an underwater adventure game. the premise is that you are a mermaid trapped in this underwater world and you need to gather 10 magical pearls to escape and win. while swimming, you run out of air so you must either swim through bubbles (a little difficult at first, but it gets easier) or go to the surface. you should avoid the sharks and lobsters. they are mean. they hurt you. jellyfish don't come after you, but if you swim through one, it will sting. you can swim right through plants but they will slow you down a little. there are also other things you must do to aquire the pearls. normally, you would need to figure them out, but i'll just tell you. - some pearls are just lying around, pick them up. - others are in treasure chests so you must find keys and open those chests. - one special turtle (the one you will see if you hang around near where you start in the game) also will give you a pearl if you pick it up and release it on another turtle (using 't' to "use" it, 'b' just drops it to swim around again). - find and use the magic wand on the sharks and lobsters to make them stand still for a whlie so you can get away. - use rocks to break the urchins to give you addtional health. you can pick up the urchins as well to save them for later, but this (along with swimming right into them) causes a little bit of damage to your health so it isn't a good idea if it is low. you will notice that when you run out of health, the "game over" noise will play, but you will immediately have your health restored. i decided to submit it like this, because it is pretty hard, and this way, you can continue to play even after you have techinically lost. also, if you win by finding ten pearls, nothing exciting happens, there is just a printf saying you win. i probably would have changed this if i won, but there was a deadline, and i just haven't won since the number of pearls to collect was raised to 10. ________________________________________________________________________________ how to run it: i have provided a macintosh executable, but the animation may look too fast or too slow depending on the processor. i have only tried it on my laptop which is a 333 mhz g3 powerbook. the file game1.mrq must be in the same folder as the executable. i would have included other game files, but i ran out of time. when you launch, you will see a plain blueish window. this was intended to be texture mapped with a cute start screen, but there was a last minute problem with the texture so it's just blue. press p (play) to begin the game. choose quit from the file menu to quit. see "user input" below for details on how to play. ________________________________________________________________________________ required graphics techniques: - 3d viewing and objects: the user can look in any direction in the 3d world, and move along that vector. the motion is intended to be similar to what you would experience underwater, for instance, while scuba diving. each key press is like taking a swimming stroke which adds to your velocity, but is capped at maximum speeds for both moving and turning. you can move faster forwards than backwards. i allowed turning in 6 dof (with much help from szymon) because this is closer to how you move when scuba diving and it made navigating easier for me after initially adjusting to not always being right side up in the world. - user input: you use the mouse to select an object that you are holding by clicking on it in the control panel. you use the following keys to move around and interact with the world: t y i o d f g j k l b accelerate: f forward d backward turn or spin: j turn left l turn right k turn down i turn up y spin counter-clockwise o spin clockwise object handling: g try to pick up the object you are looking at (within distance range) b drop the currently selected object from your holdings t try to use the currently selected object from your holdings object handling: you can pick up or have an object as the target of your use if you are facing it and it is somewhat centered on your screen. you also need to be fairly close to the target object. (this distance adjusts for certain things - you don't have to be in the sharks mouth to use the magic wand on it). - lighting and smooth shading: there is one main light source in the game. it is intended to be like the sun, so it is directional, simply pointing down. most of the objects show smooth shading. the top shell of the turtle however, has flat shading to emphasize the facets. i also made use of fog to resemble visibility issues under water. this has a nice effect, but was kind of challenging to get correct when used in conjunction with blending. the translucent bubbles and jellyfish have fog disabled which left a pretty nice effect. it was also difficult to get the surface of the water to blend into the fog. this is because the opengl pipeline does not do fog after blending, as dave finally explained, which allowed me to make the appropriate changes so the surface looks correct. i also made the color of the fog and background (clear color) darker towards the ocean floor and lighter towards the surface. it changes completely when you go above the surface out of the water. - texture mapping texture mapping is used for the floor, the clouds, and the surface of the water. the sandy floor and clouds are both done the same way, tiling seamless .rgb textures on a large square. the surface of the water is done by blending caustic patterns described in alpha textures onto a large square. there are 32 patterns that get iterated over to produce the motion. these textures extend one square beyond the edge of where the user can go in the world so that it doesn't look like the world just stops, and then the fogging makes them fade away. ________________________________________________________________________________ advanced features: - 2d control panel: the control panel displays 4 aspects of the players state: (from left to right) air and health are shown with the blue and red bars. they are independent unless you run out of air which causes your health to drop quickly. the objects you are holding are shown with little 2d icons. you can have one object selected at a time, which is outlined with green. the objects you can pick up in this game include rocks, urchins, the magic wand, keys, turtles, and pearls (which are displayed separately in the control panel). there is also a 2d map which indicates where you are in the world. it only shows movement in x and z, so it will not show your vertical depth under water. as you aquire pearls, they are displayed in the open oyster shells. - view frustum culling: i implemented partial view frustum culling. the world is divided into a grid. as you move through the world, only the grid squares near enough to you are even tested to see if the objects in the should be drawn. so if you are in a corner of a grid square, four squares will be tested. before an object is drawn, it then does a test to see if it is in front of the camera, or behind the camera. if it is behind the camera, it does not draw. an objects is determined to be behind the camera if the dot product is less than a small negative constant, this way, if something is only slightly behind the camera, and may extend in front of it, it will still draw. since the objects have rectangular bounding boxes, distance is determined by subtracting the largest radius from the distance between the objects center and the camera. - level of detail control this is done at the same time as view frustum culling. if the object has passed the test to draw itself, then its level of detail is determined based on how far it is from the camera. this is used for determining slices and stacks in the tessellated glut primitives. - collision detection this also makes use of the grid. i handle the collision detection in two ways. first i check the players grid square to determine if the player has moved into any immobile objects, like a sea urchin. if this happens, the player will 'bounce' off of it a little. occassionally if you are grazing along something, you will need to turn more away from it to move. next, each moving object, as it moves checks to see if it collides with the players new position. this is how the shark, lobster, and jellyfish determine if they have run into you and should do damage to your health. only objects in your near squares move. there is also code in place to determine if the moving objects are colliding with the other objects in the game. however, i chose to not use it because i didn't have time to correctly handle these cases so it didn't look funny, and it really doesn't look very weird with the fish swimming through eachother. if i had a little more time i would have at least kept the crayfish from walking through the treasure chest and other stationary objects. collision detection is also used when the player picks up a couple objects, rocks for example, swims upwards, then drops them one at a time. they fall down and will land in a stack on top of eachother. - sound there are several sound effects you will notice in this game. they are pretty self explanatory, except maybe the cough, which happens when you are low on air. there are 4 sound channels, so up to four effects can be played at once. - ai (simple...) the fish, turtles, lobsters, and sharks have very primitive artificial intelligence. they are determine where to move based on where the object is in its grid square (to contstrain its range of motion) and sometimes based on where the player is. the exact movement is slightly randomized, creating a pretty realistic looking effect. the shark and lobster are able to find the player very effectively in a way that looks natural. i really like the turtle, it swims for a while, then paddles its fins when it turns. the creatures do not learn or anything, so i suspect it isn't quite artificial intelligence, but i thought i would mention it. - game level editor (not completed, but...) this is something i would have liked to done with more time. the world is read in from a text file, which includes the type and location of objects. the file also includes the state of each object (for example, whether a treasure chest is open or closed, how tall a plant is, if a sea urchin has been broken by a rock, etc...). the last information in it is if the object contains another object, such as the treasure chests containing various things and the turtle containing a pearl (could be anything though). so if we had another week to do the project, i would have also written a graphical editor. ________________________________________________________________________________ external sources for inspiration: my main inspirations for the game are scuba diving and the aquariums that fill our apartment. i also thought an underwater game would be particularly fun to write since there would be some neat graphics effects to capture (bubbles, fog, depth)... the adventure gameplay is reminiscent of the nintendo game that i was completely enthralled with in seventh grade, the original legend of zelda. i haven't really played video games much since then, but most seem to involve lots of shooting or killing things, which doesn't interest me. i guess this is kind of a "girly" game in that respect, but i like it that way... and at least it isn't dress up barbie. models and other game content: all of the models in this game were original. the shark, key, treasure chest, and plants were all made by specifying vertices and some normals. then i realized it is much easier to use the glut primitives and scale them even if it might be slower. so the fish, turtle (my favorite), crayfish, sea urchin, rocks, magic wand, and bubbles are all done that way. * side note - the fish is modelled off of one of our fish named lightning. he is a mono (they live in partially salty water) and is a little sick right now so we are wishing him a complete and speedy recovery. most of them are in display lists, except for some of the moving parts, like the turtles front fins and the crayfish's legs and claws. also, ones that use level of detail are not in display lists, but they are mostly pretty simple. my sound files are mostly from .wav files off of old pc-gamer cd's (not mine). i also found a few on the web, but i didn't write down the url's. the texture maps for the sand and clouds i found on the web off one of the links that was recommended on the newsgroup (by dave i think). http://www.geocities.com/SoHo/Studios/3562/tex.html the texture maps for the surface came with the "underwater" example which is one of the many example opengl programs that ended up on my computer when i downloaded the libraries from apple. the files texload.c/h also came with this example. ________________________________________________________________________________ finally... i want to thank all of the ta's and prof. levoy for patiently answering my numerous, numerous questions. i also want to credit craig scovill (my boyfriend, not a student) for helping me by drawing the models and improving the gameplay tremendously with advice on how fast the creatures should move, how fast you should run out of air, how much damage a shark attack should do... lots of the details that really improved the game.