Example #1
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            var keys = Keyboard.GetState();
            var root = viewedChunk.root;

            if (keys.IsKeyDown(Keys.S) || keys.IsKeyDown(Keys.Down))
            {
                viewedChunk = WorldOperations.getChunk(chunkSize, world, root.Item1, root.Item2 + 1);
            }
            if (keys.IsKeyDown(Keys.W) || keys.IsKeyDown(Keys.Up))
            {
                viewedChunk = WorldOperations.getChunk(chunkSize, world, root.Item1, root.Item2 - 1);
            }
            if (keys.IsKeyDown(Keys.D) || keys.IsKeyDown(Keys.Right))
            {
                viewedChunk = WorldOperations.getChunk(chunkSize, world, root.Item1 + 1, root.Item2);
            }
            if (keys.IsKeyDown(Keys.A) || keys.IsKeyDown(Keys.Left))
            {
                viewedChunk = WorldOperations.getChunk(chunkSize, world, root.Item1 - 1, root.Item2);
            }

            base.Update(gameTime);
        }
Example #2
0
        protected override void Initialize()
        {
            base.Initialize();

            //set up screen
            _graphics.PreferredBackBufferWidth  = screenWidth;
            _graphics.PreferredBackBufferHeight = screenHeight;
            _graphics.ApplyChanges();

            world       = WorldOperations.generateWorld(worldSize);
            viewedChunk = WorldOperations.getChunk(chunkSize, world, 0, 0);
        }