示例#1
0
        public void Update(MouseHandler mouse, GameTime gametime)
        {
            if (mouse.position.X > maxX)
                position.X += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            else if (mouse.position.X < minX)
                position.X -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            if (mouse.position.Y > maxY)
                position.Y += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            else if (mouse.position.Y < minY)
                position.Y -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);

            if (position.X + GraphicsDeviceManager.DefaultBackBufferWidth >= mapWidth)
                position.X = mapWidth - GraphicsDeviceManager.DefaultBackBufferWidth;

            else if (position.X < 0)
                position.X = 0;

            if (position.Y + GraphicsDeviceManager.DefaultBackBufferHeight >= mapHeight)
                position.Y = mapHeight - GraphicsDeviceManager.DefaultBackBufferHeight;

            else if (position.Y < 0)
                position.Y = 0;

            viewMatrix = Matrix.CreateTranslation(new Vector3(-position, 0));
        }
示例#2
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.
     texture     = Content.Load <Texture2D>("Cell");
     spriteBatch = new SpriteBatch(GraphicsDevice);
     grid        = Grille.Parse(Content.Load <Texture2D>("map1"));
     cam         = new Camera(grid);
     mouse       = new MouseHandler();
     changed     = new List <Cell>();
     // TODO: use this.Content to load your game content here
 }
示例#3
0
        public void Update(MouseHandler mouse, GameTime gametime)
        {
            if (mouse.position.X > maxX)
            {
                position.X += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            else if (mouse.position.X < minX)
            {
                position.X -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            if (mouse.position.Y > maxY)
            {
                position.Y += (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            else if (mouse.position.Y < minY)
            {
                position.Y -= (float)(speed * gametime.ElapsedGameTime.TotalSeconds);
            }

            if (position.X + GraphicsDeviceManager.DefaultBackBufferWidth >= mapWidth)
            {
                position.X = mapWidth - GraphicsDeviceManager.DefaultBackBufferWidth;
            }

            else if (position.X < 0)
            {
                position.X = 0;
            }

            if (position.Y + GraphicsDeviceManager.DefaultBackBufferHeight >= mapHeight)
            {
                position.Y = mapHeight - GraphicsDeviceManager.DefaultBackBufferHeight;
            }

            else if (position.Y < 0)
            {
                position.Y = 0;
            }

            viewMatrix = Matrix.CreateTranslation(new Vector3(-position, 0));
        }
示例#4
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.
     texture = Content.Load<Texture2D>("Cell");
     spriteBatch = new SpriteBatch(GraphicsDevice);
     grid = Grille.Parse(Content.Load<Texture2D>("map1"));
     cam = new Camera(grid);
     mouse = new MouseHandler();
     changed = new List<Cell>();
     // TODO: use this.Content to load your game content here
 }