Example #1
0
        //Move DOWN -- @Soeed1 -- NOT used
        public bool canMoveDown(PlayArea Area, B1tTracker existingBits)
        {
            bool canMove = true;

            //Check 0; Out of bounds
            if (this.PosY + this.vSpeed >= Area.Height)
            {
                return(false);
            }

            //check 1: if row contains ANY 1s
            if (!existingBits.rowTracker[this.PosY + 1].Contains('1'))
            {
                return(true);
            }


            string toCheck = existingBits.rowTracker[this.PosY + 1].Substring(this.firstX, this.toPrint.Length);

            toCheck = toCheck.Replace(' ', '0');
            int Check = Convert.ToInt32(toCheck, 2);

            if ((Check & this.intValue) > 0)
            {
                canMove = false;
            }

            return(canMove);
        }
Example #2
0
        //Move LEFT/ RIGHT
        public bool canMoveSides(PlayArea Area, B1tTracker existingBits)
        {
            bool canMove = true;

            //Check 1: Adjust speed withing Bounds
            for (int speed = Math.Abs(this.hSpeed); speed >= 0; speed--)
            {
                if (this.firstX - speed >= 1 && this.hSpeed < 0) // check left
                {
                    this.hSpeed = -speed;
                    break;
                }
                if (this.lastX + speed <= Area.Width - 2 && this.hSpeed > 0) // check right
                {
                    this.hSpeed = speed;
                    break;
                }
            }

            //Check 2: row below contains any 1s
            if (!existingBits.rowTracker[this.PosY].Contains('1'))
            {
                return(true); //if no 1s then always true
            }

            //Check3
            int newspeed = 0;

            for (int col = 0; col <= Math.Abs(this.hSpeed); col++)
            {
                if (existingBits.rowTracker[this.PosY][this.firstX - col] == '1' && this.hSpeed < 0)
                {
                    newspeed = -col + 1;
                    break;
                }
                else if (this.hSpeed < 0)
                {
                    newspeed = -col;
                }
                if (existingBits.rowTracker[this.PosY][this.lastX + col] == '1' && this.hSpeed > 0)
                {
                    newspeed = col - 1;
                    break;
                }
                else if (this.hSpeed > 0)
                {
                    newspeed = col;
                }
            }
            this.hSpeed = newspeed;

            return(canMove);
        }
Example #3
0
        //MOVE DOWN with SPEED
        public bool canMoveDownSpeed(PlayArea Area, B1tTracker existingBits)
        {
            bool canMove = true;

            //Check 0; Out of bounds

            for (int speed = this.vSpeed; speed >= 0; speed--)
            {
                if (this.PosY + speed < Area.Height)
                {
                    this.vSpeed = speed;
                    break;
                }
            }

            int newspeed = 0;

            for (int speed = 0; speed <= this.vSpeed; speed++)
            {
                string toCheck = existingBits.rowTracker[this.PosY + speed].Substring(this.firstX, this.toPrint.Length);
                toCheck = toCheck.Replace(' ', '0');
                int Check = Convert.ToInt32(toCheck, 2);

                if ((Check & this.intValue) != 0) // can NOT pass
                {
                    newspeed = speed - 1;
                    break;
                }
                else
                {
                    newspeed = speed;
                }
            }

            if (newspeed == 0)
            {
                return(false);
            }
            else
            {
                this.vSpeed = newspeed;
                return(canMove);
            }
        }