Ejemplo n.º 1
0
        //Move the Snake Use Add a head new and clear the tail Method
        public void Slither(Point newLocation)
        {
            SnakeSegment newhead = new SnakeSegment(newLocation, this.m_width);

            this.m_segs.Enqueue(newhead);
            this.m_segs.Dequeue();
        }
Ejemplo n.º 2
0
        //Add a SegMent to the front of the queue
        public void Add(Point newLocation)
        {
            SnakeSegment newhead = new SnakeSegment(newLocation, m_width);

            //Check if the Queue Exists
            if (m_segs == null)
            {
                m_segs = new Queue(MAXSNAKELENGTH);
            }
            else if (m_segs.Count == MAXSNAKELENGTH)
            {
                //if full
                Slither(newLocation);
                return;
            }

            m_segs.Enqueue(newhead);
        }