0 Replies - 150 Views - Last Post: 05 February 2013 - 08:26 PM Rate Topic: -----

#1 tesseract36  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 6
  • Joined: 26-January 09

C# XNA: Drawing 2D Shadows

Posted 05 February 2013 - 08:26 PM

I'm working on a 2D game engine (Side Scrolling / Platform) with a lighting system that takes an array of points and sizes and draws gradient circles for the "lights" but when drawing this over my game you can see through the walls, so I'm trying to add shadows to the game.
Only the ground/environment will cast shadows (Maybe this will change, probably not), this is a tile based side scrolling game like terraria.

What I'm thinking is to calculate the triangles based on the angle of the line from the center of the light to the corners of each tile within the lights range and then using the DrawUserPrimitives to draw the triangles to shade in the shadows.

My concerns are:
1) Can I use DrawUserPrimitives to draw to a RenderTarget2D.
2) Is there a simpler / less intensive way to do this.

Feel free to ask for any source-code. I Attached an image to illustrate the lighting system and where the shadows are coming from. The legth of the shadow doesn't matter as they will go off-screen.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1