Example #1
0
        public Form1()
        {
            InitializeComponent();

            mGen = new Generator();
            mGen.AddRule('F', "FFF+F+FFF+F+F+FF-F-FFF-F-F");
            mGen.AddAction('F', moveForward);
            mGen.AddAction('+', turnLeft);
            mGen.AddAction('-', turnRight);
            mGen.AddAction('[', pushToStack);
            mGen.AddAction(']', popFromStack);
            mGen.TraversalComplete += (() => { mDrawingPanel.Refresh(); });

            mState = new CurrentState();
            mState.currentLocation = new Point(256, 256);
            mState.currentAngle = 90.0f;

            targetLocation = mState.currentLocation;

            executionStack = new Stack<CurrentState>();

            drawingBitmap = new Bitmap(mDrawingPanel.Width, mDrawingPanel.Height);

            mDrawingPanel.Paint += mDrawingPanel_Paint;
        }
Example #2
0
 private void pushToStack()
 {
     CurrentState stateToPush = new CurrentState();
     stateToPush.currentAngle = mState.currentAngle;
     stateToPush.currentLocation = new Point(mState.currentLocation.X, mState.currentLocation.Y);
     executionStack.Push(stateToPush);
 }
Example #3
0
 private void popFromStack()
 {
     mState = executionStack.Pop();
 }