Beispiel #1
0
        /// <summary>
        /// Changes the screen object with any changes from the register.
        /// </summary>
        /// <returns>The current screen</returns>
        public Screen Render()
        {
            //Console.Clear();

            var itemsToRender = _currentRegister.GetChangedItems(); // Gets a list of items that have changed since last render.
            var deletedItems  = _currentRegister.GetDeletedItems();


            foreach (var item in itemsToRender)                                                                                                                     // Go through each changed item
            {
                _screen.AddToScreen(new int[] { (int)Math.Floor(item.PreviousLocation()[0]), (int)Math.Floor(item.PreviousLocation()[1]) }, item.ItemPixels(true)); // Clear where the item used to be.

                _screen.AddToScreen(new int[] { (int)Math.Floor(item.StartingLocation()[0]), (int)Math.Floor(item.StartingLocation()[1]) }, item.ItemPixels());     // Draw the item in the new position
            }

            foreach (var item in deletedItems)
            {
                _screen.AddToScreen(new int[] { (int)Math.Floor(item.StartingLocation()[0]), (int)Math.Floor(item.StartingLocation()[1]) }, item.ItemPixels(true)); // Clear where the item used to be.
            }



            return(_screen); // Return the new screen object
        }