コード例 #1
0
ファイル: ConsoleRenderer.cs プロジェクト: hatrox/frogger
        public void EnqueueForRendering(GameObject obj)
        {
            char[] objImage = obj.GetImage();

            int imageCols = objImage.Length;

            Coordinates objTopLeft = obj.GetTopLeft();

            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols);

            for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
            {
                if (col >= 0 && col < renderContextMatrixCols)
                {
                    renderContextMatrix[objTopLeft.Row, col] = objImage[col - obj.GetTopLeft().Col];
                }
            }
        }
コード例 #2
0
ファイル: Engine.cs プロジェクト: hatrox/frogger
        public void AddObject(GameObject obj)
        {
            if (obj is Vehicle)
            {
                Vehicle tempVehicle = obj as Vehicle;
                for (int i = 0; i < tempVehicle.Length; i++)
                {
                    this.allObjects.Add(new Vehicle(new Coordinates(tempVehicle.TopLeft.Row, tempVehicle.TopLeft.Col + i), tempVehicle.Speed));
                }
            }
            else if (obj is Frog)
            {
                playerFrog = obj as Frog;
                this.frogStartingPosition = playerFrog.TopLeft;
            }

            this.allObjects.Add(obj);
        }