Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make something already done by a lot of games , which is when I am taking so much hits from enemy red screen drawn like the following , using XNA 4.0:

after it's drawn and I am still alive I want to be removed slightly as in the call of duty !!!

enter image description here

share|improve this question
You can make it so that a red image with alpha transparency simply is rended over, whenever you take a hit. – Mutoh May 22 '13 at 22:01
thanks Mutoh , Ok I know the strategy , but I am not graphics programmer so if you can just post any code you have :) – Mohammad Ahmed May 22 '13 at 22:05
Hi Mohammad, What Mutoh is saying is to basically create a texture in Photoshop(or your favorite image editor of choice) perhaps with some sort of radial transparency in the center of your image. Add that certain image to your XNA project. Now when the user get hit you just display it across the screen. You can scale it using XNA's rect. If you want to get fancy then perhaps you can fade the damage texture onto the players HUD. Lets say the player gets hit with a bullet that's worth -10 hp. We increment the fade factor(or alpha value) by 15 for each bullet that he gets hit with. – Grey May 22 '13 at 22:20
Code Assassin thaaaanks brother :) – Mohammad Ahmed May 23 '13 at 13:05
up vote 3 down vote accepted

Since I am not familiar with shaders at all - I recommend this approach:

Create a texture in your favorite editor whether it be GIMP or Photoshop. Leave some sort of radial transparency in the center of the image so the player can actually see what he/she is doing amidst the red bordering the edges of the screen. Add that image to your XNA project, and scale it to fit the screen(or your players HUD - however you want to do it). When you get hit or get fall damage you simply display the image.

If you want to get fancy I would suggest using an alpha value to fade the image in based on the amount of damage you are taking. You should also have some sort of cool down factor so the image wont stay on the screen for long. Let us assume your player gets hit with a weapon that causes about 20% damage. Well you should "fade in" that texture's alpha to your desired X value based on the weapon that just hit them. You would then start the cool-down timer which fades the image away at your desired Y amount. The timer will reset itself again if the player gets hit. You may want to add some sort of delay on this timer.

share|improve this answer
greeeeeeeeeeeeeeeeeeeeeeat , thaaaaanks very much I will try it – Mohammad Ahmed May 23 '13 at 13:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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