The
final project was supposed to put all the things we learned about OpenGL into
one big cool project.
For
our project we made a first person 3D video game. The player is in maze and the
goal of the game is to collect colored teapots and place them into their
matching bin. Some features:
You
can download and browse the source code on github.com at joegle/Light-Game Run 'make'
or compile:
g++ -lglut -lGLU game.cpp -o gameA world object
has a vector for each kind of thing in the world (Teapot, Bin, Switch, Light)
and will loop through the vector to draw each thing by call their 'draw()'
There are 4
sub objects that all have similar structure (also check the '.h' files):
Wall
information is stored in a matrix
In the
beginning we decided to use github.com to host
our code. Team members can download the latest version of the code and make
changes concurrently with the other team members. The version control also lets
us have access to every version of the project. The website is interfaced with
the git program and we learned the concepts
needed to use the system.
It turned out
to be a nice way to manage our group project and we can foresee ourselves using
the system in the future. There was some confusion sometimes but nothing that
online help couldn't help with.
Some thought
had to put into how to logically organize the project. The choice to have a
world class and dude class seemed obvious but the internals of those classes
had to be giving a loose frame work. At one point the dude and world instance
needed to interact and the decision was made to make the dude have a pointer to
the world instance.
There may be
some redundancy in our data model but the extra time it would of taken to make
everything perfect would not have been would saving a little bit of memory and
efficiency was kept very high.
Programming
could get very confusing. Sometimes you could change code and not see any
difference or some thing is not showing up at all in the game when it
should. With a large project like ours you can't trust that the whole chain
of calls has ran smoothly prior to the call of the current function your
working on. You must instead some how isolate the testing of your function and
incrementally building on single parts you know work.
Working with
huge source files is really annoying and unnecessary but working with a large
number of dependent sources was a little like fitting a puzzle together. It took
some time to figure out the right include order and this also helped shaped our
functional topology. Also, it was found that our first version would not
compile in Windows because g++ is less strict (or smarter) then visual studio,
so our headers and source files had to shaped up better.
Collision Detection
We implemented
collision detection by checking the bitwise anding the information read in from
the walls. We made sure to detect the wall at a far enough distance so that no “jumping”
motions were seen. An interesting point to make is that once you write the code
for forward collision detection – which you should place into a function for
repeated use – you only need to rotate the user and call that function in order
to detect walls in the left, right, and reverse directions.
Textures
We textured our
floor and ceiling with a bathroom-tile-like material, and our walls consist of
a stone texture. We wanted to produce finer textures with a higher resolution,
but we simply didn’t have the time to break down/ rewrite the texture
processing file given to us in class. Once all was finished, we had a fully
textured level, however.
First, we
wanted to take advantage of the fact that each light has a number by making a
“wrapper” function of sorts. We created a switch statement that returned a
Glenum (in this case LIGHT0-LIGHT7) depending on which n is passed into the
light object’s constructor. Each of these lights was then tied to a toggle
switch through a 1:1 ratio. Each time the toggle switches were pressed or
depressed, the light would react by being enabled or disabled. Things got more
complicated as we started to make our level larger and darker…