This project is read-only.

How to fix the Vector2 bug?

Jul 8, 2013 at 7:25 PM
Currently in XNA 4.0, you draw sprites via Vector2 like below (assuming 800x600 display):

spriteBatch.Draw(tileset, vector2, rect, Color.White);

Where vector2 = new Vector2(int x, int y). The X and Y values are between 0 and 800 or 600. Position on the screen.

However, Krypton's own vector and x/y values do not match up with XNA... For instance, if I use x = 32 and y = 32, the light is off the screen.

Has anyone else ran across this bug with Krypton?
Jul 14, 2013 at 1:59 AM
this is not a bug for krypton uses its own coordinate system
one easy way to fix this problem is to change the lines in the draw code
from this
Matrix view = Matrix.CreateTranslation(new Vector3(0, 0, 0) * -1f);
Matrix projection = Matrix.CreateOrthographic(this.mVerticalUnits * this.GraphicsDevice.Viewport.AspectRatio, this.mVerticalUnits, 0, 1);
to this
Matrix view = Matrix.CreateTranslation(new Vector3(graphics.PreferredBackBufferWidth / 2, -graphics.PreferredBackBufferHeight / 2, 0) * -1f);
Matrix projection = Matrix.CreateOrthographic(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0, 1);