예제 #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            this.Services.AddService(typeof(SpriteBatch), spriteBatch);

            system = new TreeSystem();

            turtle = new Turtle(this);
            turtle.Operations.Add('a', () => turtle.Draw(dist));
            turtle.Operations.Add('b', () => turtle.Draw(dist));
            turtle.Operations.Add('m', () => turtle.Move(dist));
            turtle.Operations.Add('-', () => turtle.Turn(MathHelper.ToRadians(-angle)));
            turtle.Operations.Add('+', () => turtle.Turn(MathHelper.ToRadians(angle)));
            turtle.Operations.Add('[', () => { turtle.Push(); turtle.Turn(MathHelper.ToRadians(-angle)); });
            turtle.Operations.Add(']', () => { turtle.Pop(); turtle.Turn(MathHelper.ToRadians(angle)); });
            turtle.Drawings.Add(system.Get(level, 1));

            base.LoadContent();
        }
예제 #2
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            turtle.Position = new Vector2(Window.ClientBounds.Center.X, Window.ClientBounds.Center.Y);
            turtle.Angle    = MathHelper.ToRadians(-90);

            spriteBatch.Begin();

            turtle.Draw(gameTime);

            spriteBatch.End();

            base.Draw(gameTime);
        }
예제 #3
0
 protected override void Draw()
 {
     Turtle.Draw();
 }
예제 #4
0
        // This brings our application back to a clean state.
        // We create a fresh new canvas the same size as the current
        // form, create a new turtle to reference that canvas,
        // and draw the turtle.
        private void InitializeCanvas()
        {
            this.pictureBox.Image =
                new Bitmap(pictureBox.Width, pictureBox.Height);
            drawingSurface = Graphics.FromImage(this.pictureBox.Image);
            drawingSurface.SmoothingMode =
                System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            turtle = new Turtle(drawingSurface);
            turtle.Reset();

            savedImage = new Bitmap(this.pictureBox.Image);
            turtle.Draw();
        }