For my simulation project, I wanted to explore the 3D aspects of p5.js, since I've only been working in 2D space for all of my previous assignments. I've never worked with 3D primitives before using code, so I decided to create a relatively simple game inspired by an iPhone app that my friends and I used to play called Boost:
The premise is as follows: the player controls a first person camera and speeds through a tunnel. There are cubes placed randomly throughout the space, and the player must dodge these cubes and run as far as possible. I felt that these game guidelines would allow me to fully explore the different avenues of working in 3D (movement in z-space, camera control, etc).
After creating the player and obstacle behaviors, all that was left to do was to add some background music, a particle system for the stars, and a simple timer. Because I ran into some issues trying to display text in WEBGL, I had to use namespacing to draw the timer on another canvas:
Gameplay Screenshots:
Unlike the game Boost, my game allows for movement along the y-axis as well, and it is not in the first-person. The use of vector motion really adds to the anti-gravity effect that I wanted to achieve. The motion is very fluid, and it is not sharp and sudden. The technique of adding to the velocity variable according to the arrow key being pressed makes it a bit more realistic; the box doesn't respond immediately to the trigger, and tends to 'float' around more.
Because this was my first step into working with 3D using code, I didn't get the chance to implement everything I wanted. Looking forward, I would like to create a player object and attach the camera to create a first-person view as well. I would also like to refine my collision detection algorithm too, because I find that as the speed increases, the box manages to phase through some of the obstacles without triggering the 'game over' function. However, I am quite pleased with the results, and it was definitely a good learning experience for 3D.