Implemented scren shake in the Camera2D class

This commit is contained in:
jme9
2025-03-19 18:59:13 -07:00
parent 0e60bb4207
commit 1c5f4b1b12
4 changed files with 102 additions and 23 deletions
+17 -1
View File
@@ -30,4 +30,20 @@ Solutions:
- We could abandon zoom in the camera and control zoom by changing the render target values.
- We should in either case only zoom at integer values to preserve pixel-perfect zoom.
Leaning towards abstracting the render target code to its own class and handling zoom there. Overall I think this will be better as it is what draws to the backbuffer.
Leaning towards abstracting the render target code to its own class and handling zoom there. Overall I think this will be better as it is what draws to the backbuffer.
## March 19th, 2025 - JME
**ScreenShake**
I have already done this in the GML version however it has to be reimplemented to work with our current class structure. We should be able to add a ScreenShake() function to the Camera2D class that takes in shake time and shake magnitude arguments.
The function will work by randomly changing the cam position between the current position + magnitude and current position - magnitude. We already have a nice function written in our LunaLigthGame class that randomly chooses a number between to set numbers. **side note** It might be nice to create a utility class and move this function over there so we can use it from anywehre.
**Refining camera movement a bit**
When the player stops the camera slows to a stop. This is good except that in the last few mometns the camera gets kinda shakey beacause the Lerp() function we are using calculates to the 5th decimal and as it approaches the final postion the camera jumps from pixel to pixel slowly.
Rather than use Lerp() let's explicitly define our follow code and once the cam position is witin a certain threshold of target position we can snap it to the target position.
**Needs more refinement**