Example #1
0
        public Citysim()
        {
            instance = this;

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = 580;
            graphics.PreferredBackBufferWidth  = 900;
            Content.RootDirectory = "Content";
        }
Example #2
0
        public void Update(Citysim game, GameTime gameTime)
        {
            // Handle movement.
            if (KeyboardHelper.IsKeyDown(Keys.LeftShift))
            {
                game.camera.speed = 15;
            }
            else
            {
                game.camera.speed = 7;
            }

            int speed = game.camera.speed;

            if (KeyboardHelper.IsKeyDown(Keys.W))
            {
                game.camera.position.Y += speed;
            }
            if (KeyboardHelper.IsKeyDown(Keys.A))
            {
                game.camera.position.X += speed;
            }
            if (KeyboardHelper.IsKeyDown(Keys.S))
            {
                game.camera.position.Y -= speed;
            }
            if (KeyboardHelper.IsKeyDown(Keys.D))
            {
                game.camera.position.X -= speed;
            }

            // Handle mouse.
            MouseState mouseState = Mouse.GetState();

            hoveringExact.X = mouseState.Position.X - game.camera.position.X;
            hoveringExact.Y = mouseState.Position.Y - game.camera.position.Y;

            hovering.X = (int)Math.Floor(hoveringExact.X / tileSize);
            hovering.Y = (int)Math.Floor(hoveringExact.Y / tileSize);
        }
Example #3
0
 static void Main()
 {
     using (var game = new Citysim())
         game.Run();
 }