예제 #1
0
        public Game()
        {
            buffer = new GameBuffer(heigth, width);

            car1 = new GameObject(0, 2, new Sprite("auto1.txt"));
            car2 = new GameObject(width - 1, 10, new Sprite("auto2.txt"));

            frogUp   = new Sprite("frog_up.txt");
            frogDown = new Sprite("frog_down.txt");

            frogInitPosition = new Position((width / 2) - (frogUp.width / 2), heigth - frogUp.height);
            frog             = new GameObject(frogInitPosition, frogUp);

            Console.CursorVisible = false;
        }
예제 #2
0
        public void Write(GameBuffer buffer)
        {
            for (int i = 0; i < sprite.height; i++)
            {
                for (int j = 0; j < sprite.width; j++)
                {
                    int x = position.x + j;
                    int y = position.y + i;

                    if ((x >= 0) && (x < buffer.width) && (y >= 0) && (y < buffer.height))
                    {
                        char c = sprite.data[i, j];
                        if (c != 'x')
                        {
                            buffer.data[y, x] = c;
                        }
                    }
                }
            }
        }