Beispiel #1
0
 public Chixel(Chixel other)
 {
     Glyph           = other.Glyph;
     ForgroundColor  = other.ForgroundColor;
     BackgroundColor = other.BackgroundColor;
     Dirty           = true;
 }
Beispiel #2
0
 public Tile(Chixel chixel, Vector2 pos, TileType type)
 {
     Chixel    = chixel;
     Position  = pos;
     Type      = type;
     Neighbors = new Tile[4];
 }
Beispiel #3
0
        private void CreateTile(Vector2 pos, Chixel ch, TileType type)
        {
            Tile tile = new Tile(ch, new Vector2(pos.X, pos.Y), type);

            FrameBuffer.Instance.SetChixel(tile.Position, tile.Chixel, FrameBuffer.BufferLayers.Obstacles);
            Game.Instance.Tiles.Add(tile);
            Tiles[pos.X, pos.Y] = tile;
        }
Beispiel #4
0
        public void Clear(BufferLayers layer)
        {
            Console.Clear();

            _chixels = new Chixel[layerCount][, ];
            for (int i = 0; i < _chixels.Length; i++)
            {
                _chixels[i] = new Chixel[Width, Height];
            }
        }
Beispiel #5
0
        public void DrawFrame()
        {
            foreach (Chixel[,] t in _chixels)
            {
                for (int x = 0; x < Width; x++)
                {
                    //if (x < 45) continue;
                    if (x >= Console.WindowWidth)
                    {
                        continue;
                    }

                    for (int y = 0; y < Height; y++)
                    {
                        if (y >= Console.WindowHeight)
                        {
                            continue;
                        }

                        Chixel ch = t[x, y];

                        if (ch != null && ch.Dirty)
                        {
                            Console.SetCursorPosition(x + _left, y + _top);
                            ConsoleColor lastFGColor = ch.ForgroundColor;
                            ConsoleColor lastBGColor = ch.BackgroundColor;

                            if (Console.BackgroundColor != lastBGColor)
                            {
                                Console.BackgroundColor = ch.BackgroundColor;
                            }

                            if (Console.ForegroundColor != lastFGColor)
                            {
                                Console.ForegroundColor = ch.ForgroundColor;
                            }

                            Console.Write(ch.Glyph);
                            ch.Dirty = false;

                            //Thread.Sleep(50);
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public void SetChixel(Vector2 pos, char c, BufferLayers layer, ConsoleColor fgColor = ConsoleColor.White, ConsoleColor bgColor = ConsoleColor.Black)
        {
            pos.X -= _left;
            pos.Y -= _top;

            if (pos.X < 0 || pos.X >= Width || pos.Y < 0 || pos.Y >= Height)
            {
                return;
            }

            Chixel ch = _chixels[(int)layer][pos.X, pos.Y];

            if (ch != null && ch.Glyph == c && ch.ForgroundColor == fgColor && ch.BackgroundColor == bgColor)
            {
                return;
            }

            _chixels[(int)layer][pos.X, pos.Y] = new Chixel(c, fgColor, bgColor);
        }
Beispiel #7
0
 public Character(Chixel chixel, Vector2 pos)
 {
     Chixel   = chixel;
     Position = pos;
     Game.Instance.Characters.Add(this);
 }
Beispiel #8
0
 public void SetChixel(Vector2 pos, Chixel chixel, BufferLayers layer)
 {
     SetChixel(pos, chixel.Glyph, layer, chixel.ForgroundColor, chixel.BackgroundColor);
 }