Question: In Scala please In the PhysicsEngine object, write a method named checkStaticCollision that takes a StaticObject and a DynamicObject as parameters and has a return
In Scala please
In the PhysicsEngine object, write a method named checkStaticCollision that takes a StaticObject and a DynamicObject as parameters and has a return type of Unit. This method will:
- Check if these objects collide (You can/should call your method from objective 1 to check for collisions)
- If they collide
- Call collideWithStaticObject on the dynamic object with the static object as an argument
- Call collideWithDynamicObject on the static object with the dynamic object and the face as arguments. The face is the face of the static object with which the dynamic object collided. This lets the static object know which of the six faces were hit by the dynamic object allowing it to react differently to collisions on different sides. Review the Face object for the variable names of all the options.
- You may assume that only 1 face collision occurs during an update and you should only test for these cases (Ex. If the collision occurs near an edge, or corner, computing the correct face becomes more difficult)
- Specifically, you may assume that the previous location overlaps with the static object in at least 2 dimensions
- If the objects were already colliding, based on the dynamic objects previous location, the colliding face should be internal.
In the tests package write a test suite named TestStaticCollision that tests this method.
Note: This method will determine the behavior of walls and platforms in the Jumper game. If the player (DynamicObject) collides with the top of a platform (StaticObject) the player will land on that platform. If the player collides with any other face, they will move through the platform. Walls (StaticObjects) will stop the player when colliding in the negativeX or positiveX directions.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
