예제 #1
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);

            switch (e.KeyChar)
            {
                case ('+'):
                    mag *= 0.5;
                    this.Refresh();
                    break;
                case ('-'):
                    mag *= 2.0;
                    this.Refresh();
                    break;
                case (' '):
                    mag = 1.0;
                    this.Refresh();
                    break;
                case ('Q'):
                case ('q'):
                    Application.Exit();
                    break;
            }

            drawnWorld = new Ant.World();
        }
예제 #2
0
        protected void PaintSquares()
        {
            var commonSquares = newWorld.Path.Intersect(drawnWorld.Path);

            drawnWorld.Path
                .Where(p => !commonSquares.Contains(p))
                .Concat( new List<Ant.Coord>{drawnWorld.Ant})
                .Select(ConvertToWorld)
                .ToList()
                .ForEach((c) => RenderSquare(c, BlockSize(), Color.White));

            newWorld.Path
                .Where(p => !commonSquares.Contains(p))
                .Select(ConvertToWorld)
                .ToList()
                .ForEach((c) => RenderSquare(c, BlockSize(), Color.Black));

            RenderSquare(ConvertToWorld(newWorld.Ant), BlockSize(), Color.Red);

            drawnWorld = newWorld;
        }
예제 #3
0
 private void UpdateWorld(object sender, EventArgs e)
 {
     newWorld = Ant.Engine.Step(newWorld);
     PaintSquares();
 }