Esempio n. 1
0
        void Pass()
        {
            ColorChanger.SetColor(1, Color);
            DefaultState state = new DefaultState(this.Parent, "Default State", new Tuple <int, int>(upDownX.Value, upDownY.Value));

            MyGame.ChangeStates(state);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (args.Length != 0)
            {
                string text = File.ReadAllText(args[0]);
                text   = text.Replace("~", "~\r\n");
                sprite = ConsoleSprite.Load(args[0], true);
            }

            //sprite = ConsoleSprite.Load(@"F:\Projekte\C#\ConsoleSprite Editor\ConsoleSprite Editor\bin\Release\netcoreapp2.2\publish\Sprites\Test.cpr", true);
            MyGame g = new MyGame();

            g.Run(new Display(DisplayType.Console, "Lucida Console", 128, 88, 8, 8));
        }
        void HandleInput()
        {
            var prevMouseX = mouse.X;
            var prevMouseY = mouse.Y;

            mouse = Input.GetMouse();
            if (Input.GetKey(Key.Escape).Pressed)
            {
                MyGame.ChangeStates(new InitialState(Parent, "Initial State"));
            }
            if (mouse.IsRightClick())
            {
                var MouseXDelta = mouse.X - prevMouseX;
                var MouseYDelta = mouse.Y - prevMouseY;

                spriteX += MouseXDelta;
                spriteY += MouseYDelta;
            }
            if (Input.GetKey(Key.LeftShift).Held)
            {
                if (scale + mouse.Z * Parent.DeltaTime < 1)
                {
                    scale = 1f;
                }
                else
                {
                    scale += mouse.Z * Parent.DeltaTime;
                }
            }
            else
            {
                colorValue.Value += mouse.Z;
            }
            var x = (int)((mouse.X - spriteX) * (1f / (scale * scale)));
            var y = (int)((mouse.Y - spriteY) * (1f / (scale * scale)));//why the f**k does this work?!?!?!?!?

            if (mouse.IsLeftClick())
            {
                activeSprite.SetChar(x, y, characterValue);
                activeSprite.SetColor(x, y, (byte)colorValue.Value);
            }
            cont--;
            if (colorValue.IsOnUp(mouse.X, mouse.Y) && mouse.IsLeftClick() && cont <= 0)
            {
                colorValue.Increment();
                cont = freq;
            }
            if (colorValue.IsOnDown(mouse.X, mouse.Y) && mouse.IsLeftClick() && cont <= 0)
            {
                colorValue.Decrement();
                cont = freq;
            }
            if (exportSprButton.IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
            {
                stateValue = State.SpriteSave;
            }
            if (importPalButton.IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
            {
                activeSprite = ConsoleSprite.Load("Test");
            }
            if (palettePanel.IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
            {
                var xPos = Parent.Screen.Width - 12;
                var yPos = Parent.Screen.Height - 2;
                colorIndex          = (short)(mouse.X - (xPos) + (8 * (mouse.Y - yPos)));
                color               = ColorChanger.GetColor(colorIndex);
                colorWindow.color   = colorIndex;
                colorWindow.R.Value = color.R;
                colorWindow.G.Value = color.G;
                colorWindow.B.Value = color.B;
                stateValue          = State.ColorWindow;
            }
            for (int i = 0; i < components.Count; i++)
            {
                if (components[i].IsInside(mouse.X, mouse.Y))
                {
                    components[i].BorderColor = 12;
                }
                else
                {
                    components[i].BorderColor = 8;
                }
                if (components[i].Clickable && components[i].IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
                {
                    components[i].BorderColor = 10;
                }
            }
            if (resetButton.IsInside(mouse.X, mouse.Y))
            {
                resetButton.BorderColor = 12;
            }
            else
            {
                resetButton.BorderColor = 8;
            }
            if (resetButton.IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
            {
                resetButton.BorderColor = 10;
                ColorChanger.SetColor(0, Color.FromArgb(0, 0, 0));
                for (int i = 0; i < 16; i++)
                {
                    ColorChanger.SetColor(i, ColorChanger.StandardColors.colors[i]);
                }
            }
            if (exportPalButton.IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
            {
                stateValue = State.PaletteSave;
            }
            if (importPalButton.IsInside(mouse.X, mouse.Y) && mouse.IsLeftClick())
            {
                ColorChanger.SetPalette(Palette.Load("TestPalette"));
            }
        }