コード例 #1
0
ファイル: CStrike2D.cs プロジェクト: DevHalo/CStrike2D
        /// <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);
        }
コード例 #2
0
ファイル: InputManager.cs プロジェクト: DevHalo/CStrike2D
 public Vector2 ScreenToWorld(Vector2 vector, Camera2D origin, Vector2 center)
 {
     return (vector + origin.Position - center);
 }
コード例 #3
0
ファイル: InputManager.cs プロジェクト: DevHalo/CStrike2D
        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);
        }
コード例 #4
0
ファイル: InputManager.cs プロジェクト: DevHalo/CStrike2D
 public int GetRow(Camera2D origin, Vector2 center)
 {
     return (int)(ScreenToWorld(MousePosition, origin, center).Y/64f);
 }
コード例 #5
0
ファイル: InputManager.cs プロジェクト: DevHalo/CStrike2D
 public Vector2 Delta(Camera2D origin)
 {
     Vector2 delta = Vector2.Transform(MousePosition, origin.Transform) - origin.Position;
     return delta;
 }
コード例 #6
0
ファイル: InputManager.cs プロジェクト: DevHalo/CStrike2D
 public Vector2 WorldToScreen(Vector2 vector, Camera2D origin)
 {
     return (vector - origin.Position);
 }