Final Project CPE471 - Portals

Spencer Woodworth


Portal World

I created a small world with several rooms that contain portals to transport the player. I was inspired by the game Portal.

Commands

w - move forward
s - move backward
a - strafe left
d - strafe right
n - duck
p - change porals
space - jump
q - quit

Overview

I decided to create a game with portals similar to the game Portal and Portal 2 by Valve. I wanted to learn more about textures and lighting, and the process of using the back buffer as a texture itself seemed like a logical choice. The game allows for the player to explore a world. There is one portal in the room that the player begins the game in. This is the ‘sending’ portal. There are 4 other ‘receiving’ portals that the user may select from using either a right click or cycling through by pressing ‘p’. When the player collides with the portal they are transported to the receiving end. They may also transport back from any of the ‘receiving’ portals to the ‘sending’ portal in the same way. The point of the video game Portal is to solve small puzzles, so I built a small puzzle into my game. At the beginning of the game the player may not transport through the last portal labeled ‘???’. There are 5 switches of different colors spread throughout the map. The player must flip these switches in the correct order in order to activate the portal.

Portal World Portal World

If the player uses an incorrect order all previous switches will be reset, so be careful. Finally the player collects the star at the receiving end of the ‘???’ to win the game.

Using Portals

To use a portal the player should stand in front of the portal and walk directly into it. But before you rush in to it, you might want to try a few other things. Try standing in front of the portal and strafing from left to right and back again. Notice what happens to the image. Now jump using ‘space’ or duck using ‘n’. Now you are ready to walk through. But don’t stop there. Try walking through the portal while strafing or walking backwards!

Portal World Portal World

Changing Portals

The first image below shows an inactive portal. The user may not use this portal and will simply collide as if hitting a wall. Unless you active this portal! The player may active portal by right clicking a selecting the portal of choice from the ‘portals’ menu, or they may cycle through the portals by pressing ‘p’.

Portal World Portal World

Features

3-Pass Draw

In order to use a different camera angle as a texture the program must draw the entire scene with a different view in the back buffer, copy it and clear the back buffer for another draw. Since there are two active portals at any given time, this requires 3 draws. 1 draw for the ‘sending’ portal, 1 for the ‘receiving’ portal, and 1 for the regular game camera.

Textures

All of the textures were either created by me, obtained from class, or downloaded from the free web texture sites webtextures.net and bgpatterns.com .

Animated Objects

There are cameras spread throughout the world watching your every move. They know when you are making mistakes with the switches. Watch as they pan across the room. The switches also animate to let you know when they are active or have been reset.

Textures Based on Time

The portals glow and change from color to color as you play the game. This was achieved by adding color to the texture based on trigonometric functions and the current system time.

Collision Detection

The player can’t walk through walls…sorry. But you may want to try that curtain in the back after all of the switches have been flipped.

Conclusion

This was a really fun project. I enjoyed being able to think of any feature that I wanted and being able to add it. Unfortunately I came down with the flu over Final week (which I was saying two days of to work on this project). This caused me to miss out on a few features that I had really hoped for. Future work could include adding sound using OpenAl, allowing the user to place portals wherever they are looking, and more challenging puzzles. Perhaps some day.


References

Collision Detection: http://www.3dcodingtutorial.com/Collision-Detection/Collision-Boxes.html

glCopyTexImage2D: http://rainwarrior.thenoos.net/dragon/texture.html

Class Notes