/Whack-a-mole

Computer Graphics project

Primary LanguageJavaScript

Whack-a-Mole!

Final project for Computer Graphics course of PoliMi (A.Y. 2020/2021) by Aida Gasanova and Marco Donzelli

How to play

Press play and move the hammer with q , w , e , a , s keys. You have 60 seconds to hit as much moles as you can!

Implementation

Tools and languages

The game is implemented in WebGL, GLSL and Javascript with the use of the following libraries:

Scene Graph

The scene graph of the game holds two main nodes:

  • cabinetSpace which contains the hammer, the cabinet and moleSpace
  • moleSpace which contains the five moles

The root of the scene graph is stored in a global variable of the app so that the method updateWorldMatrices() can be called on it and all the local matrices of child nodes get updated accordingly with changes performed meanwhile.

Lights and BRDFs

The game is illuminated with two type of ligths, implemented in camera space:

  • direct light still, can't be controlled by the user
  • spot light direction controllable by the user along with usual spot parameters such as coneIn,coneOut, etc.

The BRDFs implemented in the shaders are the Lambert model for the diffuse part and Phong for the specular part.

Also ambient light is implemented by simply summing a term in the output vector that provides a little bit more of the colour from the texel.

Skybox

We implemented a separate WebGL program and drawing pipeline to draw a "skybox" type object which surrounds the main scene.