Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So a few days back, I started playing around with Krypton XNA for 2D lighting in my game.

I noticed in general, that spawning a light at (0,0) with Krypton causes the light to appear in, pretty much, the centre of the game screen. Is there any way to change this so a Krypton light's "starting point" at [0,0] would spawn at the top left of the screen, and thus follow the standard screen co-ordinates for position?

I ask because currently I'm busy working on my game where my spawn point is [512,512]. With hard code, the closest I've got to the light being "central" to this point is the vector position [12,-20], which makes no sense and is impossible to craft, mathematically, if I want the light to move with the camera (the position [480,512] maps roughly to [10,-20]).

So, is there any way to "normalise" the krypton lights to use standard screen co-ordinates?

If you guys can, play around with the demo from the site and please see if you can find anything out about it. Documentation on the engine is rather scarce, so it's difficult to find anything relevant to my "pixel-perfect" need. It might just also be something in the code with regards to the matrices that I'm not fully understanding.

Any help would be useful.

Thanks.

share|improve this question
    
You can't simply take the width of your screen and subtract that from the starting point? ie spawn a light at [-450,-720] if your screen is 900x1440 and it will be in the top left corner. I'm not used to xna (hence im only commenting) but is there no way to get the screen's height and length? –  hammythepig Jul 23 '12 at 21:00
    
Alas, no luck there. Again, this all comes down to, I think, Krypton's non-pixel based vector co-ordinate system where, for example, 12 units along the X axis is actually around 512 pixels. Like I said, however, this measurement system feels fairly arbitrary and I can't figure out the math behind it. –  Adam Jerrett Jul 23 '12 at 21:44
    
Oh I see, 12 units is equal to 512ish. I didnt get that from the question. Hmmm, seems like an unusual problem indeed. –  hammythepig Jul 23 '12 at 21:46

1 Answer 1

I am the creator of Krypton - Christopher Harris.

SpriteBatch uses pixels as it's default unit. Krypton does not have a default unit. Imagine "1px" vs "1" vs "1km". Krypton's units would simply be "1".

You'll need to either adjust Krypton's matrix to compensate for the variation by enabling "SpriteBatch" mode on Krypton, or by adjusting SpriteBatch's matrix, which can be accomplished via an overload to the Begin call.

There has been some confusion about how to do this easily, and my attempts to make the framework easily usable with SpriteBatch have thus far been less than satisfactory. I will be making some improvements within the next month or two, as I will need this feature for a game I am currently working on.

share|improve this answer
    
by enabling "SpriteBatch" mode on Krypton by doing this: KryptonEngine.SpriteBatchCompatablityEnabled = true; ? –  Cypher Sep 21 '12 at 0:00
    
Correct. That should compensate for the scaling / translation issues. However, you will also need to change the cull mode when you do this, as it reverses the direction triangles are rendered. You can set the cull mode to none for testing purposes. Let me know if you have any issues –  Christopher Harris Sep 21 '12 at 1:02

Your Answer

 
discard

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.