Bob Somers   Chris Gibson   Sean Forsberg   Kennedy Owen   Clovas Hansen   David Haken
Play Compilation Video

About

When you were a kid a built towers with blocks, what's the first thing you did after building a city? Knock it down! In short, Two Cities is about one thing: knocking over stacks of blocks!

You and a friend compete to see who can do the most damage to each other's city. First, you build your cities using our integrated city builder. When you're both ready, the game changes to carnage mode and the destruction begins! Use one of the six different ammo types to wreak havoc upon your enemy's city! As blocks are knocked away from their starting position, you gain points which earn you special ammo. When one of the players damages 95% of their opponents city, the game ends and the player with the highest score wins!

Features and Controls

Two Cities builds both a dedicated server and a client executable. The client is capable of hosting a server, but for best performance we suggest using a dedicated server to offload the physics simulations from the clients. Note that the client takes two flags, "-pretty" which enables bloom and additional shader effects (low powered machines need not apply) and the "-fullscreen" flag which runs the game in full screen mode.

The game controls are as follows:

Key Technologies

City Builder

To build a city, the user needs intuitive controls for creating objects in the 3D scene. The problem is that we only have a 2D interface (the screen) to our 3D world. The city builder works by taking mouse coordinates from the screen and using gluUnProject() against a plane to determine the world coordinates of the click. The user can also resize existing buildings by clicking a dragging a face, using a push-pull system similar to Google SketchUp.

Networked Physics

Networking a massive physics simulation in real time is no trivial task. As every block is simulated, we need to synchronize its position and rotation between all players in the game. We used a standard server/client architecture to do this, with the authoritative physics simulation being performed on the server. To ensure that updates were sent to the clients in an intelligent way, the network system schedules the packets according to their speed from the physics system, so blocks that are moving rapidly have a higher priority of being included in the next update. Lastly, because its unrealistic for clients to receive network updates for every object in the world before rendering their next frame, we use client-side prediction for all blocks using a simple ballistic model and linearly interpolate with authoritative updates when they arrive.

Shaders Galore

The requirements of the project included writing one pixel shader, but we ditched nearly the entire fixed-function pipeline in favor of shaders. To attain the visual feel we were going for (dark, glowy, and digital) we found it easier to write custom shaders for most objects rather than attempt to wrangle the fixed-function pipeline into doing what we wanted. All the blocks and ammo, the gridded playing field, the skyscrapers in the background, the circuit skyline in the distance, the constantly changing cloud patterns, and several effects are all written using GLSL shaders; eleven shaders in total.

Adaptive Bloom

Screen-space effects like bloom, blur, and glow can provide an enormous amount of visual complexity to a scene, but can also incur a huge performance cost. Because these effects are modified in post-processing, the larger the frame buffer the larger the cost. To prevent our bloom shader from drastically affecting the game's performance, we created a feedback look in our bloom shader to effectively "dial it down" when the rendering load became too great. The shader uses timings from the past several update loops to determine on the fly how many samples to take for each frame of bloom. As the game heats up, the shader automatically relaxes its demand on the rendering pipeline until the resources are available to crank up the effect. In practice, this works extremely well, as no visual artifacts are noticeable and the framerate is steady.

Debugging Console

When working on a game, it can be a pain to switch back and forth to the console output to see debugging printf()'s and type in commands. Thus, we built an in-game console that provides text-based i/o for developers. Code can print to the console using printf() style commands at one of three warning levels, and it can register its own command processing hooks as well. For example, the network system registers several network commands that receive their console command line arguments similarly to the way a Unix command line program does: with argc and argv. The console also shows several other pieces of crucial debugging information, such as the SVN revision number it was built from, the current number of packets being transmitted and received, the loop update time (in milliseconds), and the number of frames per second rendered.

Requirements

Two Cities requires very few things to be installed to compile and play the game. In fact, the only two things needed are the GLUT development headers (usually called freeglut-devel in your package manager) and the SDL development headers (usually SDL-devel). It uses several other libraries (Bullet, FreeType, OGLFT, SDL_mixer, libogg, libvorbis, and Ting) but they are all included and compiled in or precompiled and linked statically. Our Lua build script automatically generates the appropriate Makefile based on the version you're building (debug/release, client/server) and handles this process automatically.

References

Libraries and Tools

Copyright Notice

Two Cities contains music taken from the Newgrounds Audio Portal. This music is licensed under the Creative Commons license, meaning it can be used and remixed so long as proper credit is given to the artists and the music is not used in an application for profit. The following artists' music tracks were used in the Spring 2010 release of Two Cities: Aleks Hell, Ben Fischl, DJ Dreamz, DJ Sonik, NemesisTheory, SamsterProductions, Zeeber85. Two Cities also contains sound effect clips taken from The Freesound Project. All sound effect clips are licensed under the Creative Commons license, as stated previously. The following artists' sound effects were used in the Spring 2010 release of Two Cities: junggle, aust_paul, THE_bizniss, smcameron, Snipperbes. Lastly, sound effects from the IBM Model M Keyboard Simulator were used in the Spring 2010 release of Two Cities. These sound effects are not being used for commercial profit, only serving to enhance Two Cities gameplay experience.