First, I wanted to make a first-person shooter in a similar vein to Wolfenstein 3D and Doom(1993). I wasn't able to do that, but I was able to get close and then turn it into a shooting gallery, sort of like Duck Hunt. First, I had I tried to make a first-person camera. I got the camera to move, but I couldn't get it to rotate or move freely. What I mean is the camera would always stare straight, and if I went past the origin, the camera would instantly turn around(It also might be upside-down, but I'm not sure🙃). I have the video here:
Next, the professor found a library called easyCam already in a primarily blank p5 project, and I was going to use it, but easyCam has a first-person variant called roverCam, and I built a room using colored planes so I could tell what wall I'm looking at. Here it is:
After that, I can't remember what I did. Apparently, I introduced the player class which extends roverCam. when I reopened the project it wouldn't run but when I got it to work I got this:
At this point, I realized I couldn't figure out how to turn the camera correctly so I threw out the original project and modified a maze demo for roverCam. After that, I was able to add enemies and their movements and collision.
Next up I added very primitive shooting and I realized that I couldn't figure out how to shoot in the direction I was looking. at this point, I started having massive reservations about this project and thought up the idea for the shooting gallery. For now, I decided to keep going.
Next, I focused on bullet collision and splicing arrays for the enemies and bullets. The bullets worked fine but when I splice an enemy when its health got low it cleared the whole array. this was because I made a mistake in the code. The mistake was the health value was being shared amongst all enemies so they were all cleared. I also started putting classes in their own files and worked on turning and shooting. but found it required me to rotate 3D vectors which required math that looked like this.
// Make sure our axis is a unit vector
axis = p5.Vector.normalize(axis);
return p5.Vector.add(
p5.Vector.mult(vect, cos(angle)),
p5.Vector.add(
5.Vector.mult(
p5.Vector.cross(axis, vect),
in(angle)
),
p5.Vector.mult(
p5.Vector.mult(
axis,
p5.Vector.dot(axis, vect)
),
(1 - cos(angle))
)
)
);
}
Since I had no clue what I was looking at I gave up and made the shooting gallery, but I saved the project so I could work on it later. Here it is:
Finally, I rotated the bullets to face forward locked the enemies, and the player to only move left to right, and added sound, a score, and a wave counter. A far cry from what I wanted, but still I'm happy with this project the full-screen project is here: