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, 2014 at 1:35

1 Answer 1

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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .