Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 public Vector2 ScreenToWorld(Vector2 vector, Camera2D origin, Vector2 center)
 {
     return (vector + origin.Position - center);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 public int GetRow(Camera2D origin, Vector2 center)
 {
     return (int)(ScreenToWorld(MousePosition, origin, center).Y/64f);
 }
Ejemplo n.º 5
0
 public Vector2 Delta(Camera2D origin)
 {
     Vector2 delta = Vector2.Transform(MousePosition, origin.Transform) - origin.Position;
     return delta;
 }
Ejemplo n.º 6
0
 public Vector2 WorldToScreen(Vector2 vector, Camera2D origin)
 {
     return (vector - origin.Position);
 }