/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); defFont = Content.Load<SpriteFont>("font/defFont"); inputManager = new InputManager(); camera = new Camera2D(); pixelTexture = new Texture2D(graphics.GraphicsDevice, 1, 1); pixelTexture.SetData(new[] {Color.White}); LoadMap("default"); WriteMap("bigmap"); camera.Position = new Vector2((newMap.TileMap.GetLength(0)/2)*64 + 32, (newMap.TileMap.GetLength(1)/2)*64 + 32); render = new RenderTarget2D(graphics.GraphicsDevice, 1366, 768, false, SurfaceFormat.Rgba64, DepthFormat.Depth24, 24, RenderTargetUsage.DiscardContents); finalRender = new RenderTarget2D(graphics.GraphicsDevice, 1366, 768, false, SurfaceFormat.Rgba64, DepthFormat.Depth24, 24, RenderTargetUsage.DiscardContents); }
public Vector2 ScreenToWorld(Vector2 vector, Camera2D origin, Vector2 center) { return (vector + origin.Position - center); }
public float MouseRotation(Camera2D origin) { Vector2 delta = MousePosition - Vector2.Transform(origin.Position, origin.Transform); return (float)Math.Round(Math.Atan2(delta.Y, delta.X), 2); }
public int GetRow(Camera2D origin, Vector2 center) { return (int)(ScreenToWorld(MousePosition, origin, center).Y/64f); }
public Vector2 Delta(Camera2D origin) { Vector2 delta = Vector2.Transform(MousePosition, origin.Transform) - origin.Position; return delta; }
public Vector2 WorldToScreen(Vector2 vector, Camera2D origin) { return (vector - origin.Position); }