Space Onslaught
Space Onslaught is a game developed as a pair with a classmate, written in C++. Before this I had not spent much time in the land of C++. However, I did spend a sizable amount of time in C during my undergrad studies, learning about pointers and such. This is a 2 player local multiplayer game where both players shoot each other with a ton of bullets and each ship has 3 hits they can take before they get destroyed and lose the game. Each ship has 2 firing modes, a slower but wider shot, and a faster but more focused shot.
Example of the ships shooting and being damaged
Shooting
For my part on the project, I created the shooting for both weapons and helped with the bullet collisions. Each spread has 5 total bullets, and each bullet has an x and y direction that is normalized to keep the speeds the same. Every bullet is then updated to a new position using delta time and a speed variable that each bullet shares.
//update the bullet's position based on the slope given to the bullet void Bullet::Update(float deltaTime) { if (shouldUpdate) { //dividing by the entire slope normalizes so the value of the angle //doesn't effect the speed due to the magnitude float xPos = GetPosX(), yPos = GetPosY(); float xUp = (xSlope / (fabs(xSlope) + fabs(ySlope))); float yUp = (ySlope / (fabs(xSlope) + fabs(ySlope))); //add to the x and y positions using the slope values and //modify them by the speed xPos += ((xUp) * (deltaTime / 100.f) * speed); yPos += ((yUp) * (deltaTime / 100.f) * speed); setPosition(xPos, yPos); } }