예제 #1
0
        public void Init()
        {
            _scene = new Scene(_width, _height);
            _snake = new Snake(_scene, new Point(_width / 2, _height / 2));

            _scene.GenerateNewFood(_snake);
            _snake.FoodEaten += OnFoodEaten;

            _snap = new SnakePresenter(_snake)
            {
                CanvasHeight = FormHeight,
                CanvasWidth = FormWidth,
                Graphics = g,
                Line = _height,
                Column = _width
            };

            _scep = new ScenePresenter(_scene)
            {
                CanvasHeight = FormHeight,
                CanvasWidth = FormWidth,
                Graphics = g,
                Line = _height,
                Column = _width
            };
        }
예제 #2
0
파일: Snake.cs 프로젝트: toowhite/snake
 public Snake(Scene scene, Point position)
 {
     _direction = (DirectionEnum)(new Random()).Next(4);
     _dead = false;
     _bodyBlock = new List<Point>();
     _bodyBlock.Add(position);
     _scene = scene;
 }
예제 #3
0
 public ScenePresenter(Scene scene)
 {
     _scene = scene;
 }