How would one of these work?
(If you don't know what I'm talking about, think like in a game where you shoot a big gun, and your screen bounces in the opposite direction.)
I've been experimenting with a couple different ideas but none are either fully working, or fully smooth.
Using this function for setting the camera position:
x = -target.x + halfScreenW;
y = -target.y + halfScreenH;
One problem I've run into is when setting the camera to move a certain distance in a direction, it will reach its target X or Y before the other, causing it to go travel in a straight line for a short while. I believe the solution to this is using the Bresenham line algorithm?
What would be the best way to achieve a camera shake?
edit: Related - Realistic Camera/Screen Shake from Explosion
you shoot a big gun, and your screen bounces in the opposite direction
That's called recoil. – starikcetin Jul 27 '16 at 00:40