This project is read-only.

Coordinates

Apr 14, 2011 at 6:24 PM
Edited Apr 14, 2011 at 6:25 PM

Hey, first off i love your engine, but i cant seem to figure out how to position the lights on my map instead of on the screen. Let me explain.

So i'm working on a tile engine/game (top-down) and implemented your engine in it, but when i place a light at a vector2D coord it places it on the coord of the screen not my map so when i move my character the light moves with it cause it stays at the X, Y 50, 50 of the screen not the X, Y 50, 50 of my map.
Got any ideas?

Keep it up btw!!

Apr 15, 2011 at 4:11 PM

Just to check - you've definitely tied it in with your camera matrix?

 

// ... in some sort of setup function:

            // Use Spritebatch compatability to gel with our camera
            krypton.SpriteBatchCompatablityEnabled = true;

        

// update - once per tick    
        public void Update(GameTime gameTime)
        {
            // update the matrix, per camera
            krypton.Matrix = _camera.Matrix;

Apr 17, 2011 at 8:14 PM

Hmm, i had no camera matrix, so implemented one wich works, but then it still draws the lights on screen coords and when i put in SpriteBatchCompatability to true it draws no lights

Aug 6, 2011 at 8:54 PM

TGIXXER,

I apologize for this extremely late response,

It seems like you may want to change Krypton's cull mode to none, or CCW (or opposite of whichever you're using now).

Hopefully this will solve the problem.

Sep 4, 2011 at 4:44 PM
Edited Sep 4, 2011 at 4:46 PM

Hey,

No problem on the late comment i havent had anytime to work on it since the comment, i got back in to it today and started over with the lighting, i added krypton to my project and then basicly took the code from the kryptontestbed and implemted that in my game then i had the same problem with the lights being in the screen coordinates so moved with the camera and not in my game scene so i read another post of you (http://krypton.codeplex.com/discussions/265481) and noticed that you modified this line "Matrix view = Matrix.CreateTranslation(cameraPosition * -1f);" and thought id give that a try so i did and with some minor changes to to the Matrix view it works like a charm, i didnt have to set any spritebatchcompatability or cullmode.

Btw this is what my Matrix view code looks like now "Matrix view = Matrix.CreateTranslation(new Vector3(camera.Position.X, -camera.Position.Y, 0) * -.1f);"

Somehow my camera Y values are negative so i need to look in to that but it works fine only thing is when i add a light it needs to have a negative Y value, also i made it * -.1f instead of -1f

It really made my game look a lot better, when im a bit further in development of my game ill post it in the How are you using Krypton? discussion.

Tnx!