4
\$\begingroup\$

I am making a 2D game and I'd like a visual cue when the player gets hurt. Currently, I have a simple blinking red dot that shows up for 2 seconds after damage, but it's not very immersive.

Many games shake the screen to indicate damage. How could I implement such an effect?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Is there anything that you have tried so far? \$\endgroup\$
    – Lysol
    Feb 22 '14 at 1:35
4
\$\begingroup\$

Define a vector that shifts the rendered position of everything.

When that vector is (0,0), the screen is still. Changing it randomly every 5-10 frames causes the screen to shake. You can smooth this change if you like.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.