Program 5: Putting it together — snake in 3D! Due Dec 11/13

Due: by final exam time:
  • For 461: Thursday, December 13th 8am
  • For 561: Tuesday, December 11th 1pm

Goal: In this assignment you will apply what you've learned of basic WebGL and GLSL to build a simple game.

Submission: Submit your assignment using this Google Form, and demo your assignment in class during the final exam period.

The main components of this programming assignment are:
  • 10% Part 0: properly turned in program (new requirements!)
  • 10% Part 1: display the playing field
  • 30% Part 2: display and animate snake
  • 30% Part 3: add food items and object interactions
  • 20% Part 4: display and interact with non-player snake 
  • Participation credit: Receive participation credit (outside of this assignment) for posting your resulting imagery and video, good or bad, on the class forum!

Our suggested game is a 3D version of Snake. If you are not familiar with the game, you can play it online herehere or here, view some historic gameplay here, and find more information about the game at its Wikipedia entry here. There are also many other sources online.

If you would rather implement a different game, you may do so, providing you obtain instructor's approval by November 27. To obtain that approval, send an email to Prof. Watson (and copy our TA) with a short description of your proposed game and begin a dialog. Small teams are also acceptable, but the scope of the project must increase to match. Again, obtain approval for teams from your instructor, to increase project scope.

Unlike previous programs, your game is not required to load specific assets (models, textures or lighting). You are free to hard-code paths to the assets your game requires.

You may use any 3rd party game or graphics libraries you find, including three.js, to earn 90% of the assignment credit. For full credit, use only WebGL. You may not use code from any implementation of Snake you find online.

Part 0: Properly turned in assignment
Remember that 10% of your assignment grade is for correctly submitting your work! For more information about how to correctly submit, see this page on the class website. Since we encourage variation in your games, make sure to include a readme file.

For this assignment only, you can also earn extra credit (461: 2%; 561: 1%) by allowing us to make your assignment public, and providing us with some extra material to aid us in that. We will pick a few of the best assignments and publish them on our course website. If you wish to allow us, please also deliver:
  • a description: your game in four sentences or less
  • a screencast: a video walking us through your game within a few minutes. We suggest using YouTube itself to capture the video, downloading the video, and then uploading it for turnin.
Assignment material is due online by the time of your final. You must also demo your game in class during the final. In exceptional circumstances, earlier demonstrations may be arranged. Late demos are not possible. Late online turn in of assignments will be accepted through December 13. They will lose 3%.

During the final exam period, you may optionally demo your assignment in front of the class. If you do, you will enter the competition for a $20 Amazon gift card. You will win if your fellow students vote your game the best. Students in teams cannot enter the competition.

Part 1: Display the playing field
Create and render the models needed for the game. You should display a roughly planar terrain surrounded by walls. Models should be 3D, though the projections may be orthogonal. Fancy modeling is not necessary; cubes and spheres are enough. No motion is required for credit in this part.

Part 2: Display and animate snake
Model and animate the snake. It moves forward until the user types a key (wasd and/or arrows) to turn it. We recommend that you implement the 2D mechanics of the game using a grid (visible or not), and that the snake be modeled with small segments, each of which fit inside a grid cell. Then when the snake's head moves in response to user input, it records its input in its grid cell for other segments to follow.

Part 3: Add food items and object interactions
Make food appear in a cell at fairly regular intervals. When the snake eats this food by entering its cell, it lengthens by one segment. Also, when the snake leaves the playing field or hits one of its own segments, it dies and is respawned with the starting number of segments.

Part 4: Display and interact with non-player snake
Add a non-player (NP) snake that moves randomly. If the player's snake hits the non-player snake, it dies and is respawned. If the NP snake hits the player's snake, itself, or leaves the field, it dies and is respawned. If the NP snake hits food, it lengthens.

Extra credit opportunities include the following, with values in format (461, 561)%:
  • (1, ⅓)% — track and display score. You can choose any scoring scale you want.
  • (1, ⅓)% — add an optional over-the-shoulder view (of the player snake, like Snake III)
  • (1, ⅓)% — add animated explosions, which appear at collisions
  • (1, ½)% — animate the motion of the snake, moving it continuously between cells
  • (2, ½)% — add two power ups, e.g. slow gameplay, turn off collisions
  • (2, ½)% — play music, and on game events play a sound, e.g. on collisions
  • (2, ½)% — support a second player, either with different keys or the mouse