Пример #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            if (Keyboard.GetState().IsKeyDown(Keys.Space))
            {
                palette = PaletteUtil.BuildGrayscalePalette().ToArray();
            }

            base.Update(gameTime);
        }
Пример #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content. Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            graphics.PreferredBackBufferWidth  = screenWidth * screenZoom;  // set this value to the desired width of your window
            graphics.PreferredBackBufferHeight = screenHeight * screenZoom; // set this value to the desired height of your window
            graphics.IsFullScreen = fullScreen;
            graphics.ApplyChanges();

            Rectangle deviceBounds = GraphicsDevice.PresentationParameters.Bounds;

            if (deviceBounds.Width != screenWidth * screenZoom || deviceBounds.Height != screenHeight * screenZoom)
            {
                throw new Exception("Screen was not properly initialized!");
            }

            canvas = new Texture2D(GraphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color);
            convertedPixelValues = new uint[screenWidth * screenHeight];

            pixels  = new byte[screenWidth * screenHeight];
            palette = PaletteUtil.LevelUpPalette(PaletteUtil.BuildDefaultVga256Palette()).ToArray();

            base.Initialize();
        }
Пример #3
0
    public static string ColorWrap(string s, Palette color)
    {
        string colorHex = PaletteUtil.Get(color);

        return($"<color={colorHex}>{s}</color>");
    }