コード例 #1
0
ファイル: Playfield.cs プロジェクト: hillgr/rotatetris
        //Description: Add a shape to the playfield
        public void AddShape(Shape theShape)
        {
            linkedblocks.Add(theShape.linkedset);//adds the set to the list

             //   if (theShape.PositionY > mHeight - 1)
              //  {
             //       theShape.PositionY = mHeight;
             //   }
             //   bool flag = false;

            //Construct a piece in the playing area and color it the current color
            for (int aBlock = 0; aBlock < theShape.mNumberOfBlocks; aBlock++)
            {
             //   mPlayfield[theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0], theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1] - 1] = theShape.Color;
                bPlayfield[theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0], theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1] ] = theShape.Blocks[aBlock];
               // if (theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1]  == 19) flag = true;
               }
        }
コード例 #2
0
ファイル: Shape.cs プロジェクト: hillgr/rotatetris
 public void copy(Shape s)
 {
     this.Type = s.mType;
     for(int i=0;i<this.mNumberOfBlocks;i++)
         this.Blocks[i] = s.Blocks[i];
        // this.DrawPositionX = s.DrawPositionX;
       //  this.DrawPositionY = s.DrawPositionY;
 }
コード例 #3
0
ファイル: GameplayScreen.cs プロジェクト: hillgr/rotatetris
        //Description: Create a new random shape
        private void CreateNewShape()
        {
            if (mNextShape.Type == Shape.ShapeType.NotSet)
            {
                mNextShape.Type = ((Shape.ShapeType)(RandomNumber(0, 8)));
            }//end if (mNextShape.Type == Shape.ShapeType.NotSet)
            mCurrentShape = mNextShape;

               // mCurrentShape.Type = mNextShape.Type;
               // for (int i = 0; i < mCurrentShape.mNumberOfBlocks; i++)
               // mCurrentShape.Blocks[i] = mNextShape.Blocks[i];
            mCurrentShape.DrawPositionY = 30;
               // mCurrentShape.DrawPositionX = mNextShape.DrawPositionX;
            mNextShape = new Shape(mPlayfield,true);

            mNextShape.Type = ((Shape.ShapeType)(RandomNumber(0, 8)));

            //Randomly set the block types of the new shape
               // int bt = RandomNumber(0, 8);
             //   for (int i = 0; i < mNextShape.mNumberOfBlocks; i++)
               //     mNextShape.Blocks[i].Type = (Block.BlockType)bt;

               // mCurrentShape.PositionX = 0;
               // mCurrentShape.PositionY = 0;
            mCurrentShape.Rotation = 0;
        }
コード例 #4
0
ファイル: GameplayScreen.cs プロジェクト: hillgr/rotatetris
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameplayScreen()
        {
            TransitionOnTime = TimeSpan.FromSeconds(1.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            mCurrentShape = new Shape(mPlayfield,true);
            mNextShape = new Shape(mPlayfield,true);
            mNextShape.DrawPositionX = 400;
            mNextShape.DrawPositionY = 10;
        }
コード例 #5
0
ファイル: Playfield.cs プロジェクト: hillgr/rotatetris
        //Description: Check to see if the current shape in play has hit something
        public bool CheckCollision(Shape theShape)
        {
            theShape.magnet = 0;
               // if (theShape.PositionX < 0 || theShape.DrawPositionX < 350)
            //{//Check to make sure is inside the grid on the left
               //     return true;
               // }
            for (int aBlock = 0; aBlock < theShape.mNumberOfBlocks; aBlock++)
            {
                int blockx=theShape.DrawPositionX+theShape.CurrentShape[theShape.Rotation, aBlock, 0]*24;
                int blocky = theShape.DrawPositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1] * 24;
                if (blockx < (Xpos)|| (blockx+24)>(Xpos+mWidth*24)) return true;//The shape must bebetwwen the sidewalls

                if (blocky+24 > (Ypos+mHeight*24) ) return true;
                //Check to see if one of the blocks that make up a shape is moving outside of the width or height of
                //the established playing area
              //  if (((theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0] > mWidth - 1) | (theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1] > mHeight - 1)))
               // {
                //    return true;
                //}

                //Check all of the block corners too see if they hit any of the blocks in the grid
                int cornerx = 0;
                int cornery = 0;
                //Lower Left corner
                cornerx = (blockx-Xpos)/24;
                cornery = (blocky + 23-Ypos)/24;
                if (bPlayfield[cornerx, cornery].getTypeInt() >= 0) return true;

                //Check to see if its about to hit something
                cornery = (blocky + 23 - Ypos + 12) / 24;
                if (cornery<20&&bPlayfield[cornerx, cornery].getTypeInt() >= 0)
                {//The block is within 12 pts of hitting another block so guide it in
                    int remainder=0;
                    remainder = (blockx - Xpos) % 24;
                    if (remainder == 0)/*yeah*/ remainder=0;
                    else if (remainder > 12)
                   {//then go right
                       theShape.magnet = 1;
                   }
                   else
                   {//go left

                       theShape.magnet = -1;
                   }

                }
                //Lower Right corner
                cornerx = (blockx + 23 - Xpos) / 24;
                cornery = (blocky + 23 - Ypos) / 24;
                if (bPlayfield[cornerx, cornery].getTypeInt() >= 0) return true;
                //Check to see if its about to hit something
                cornery = (blocky + 23 - Ypos + 12) / 24;
                if (cornery < 20 && bPlayfield[cornerx, cornery].getTypeInt() >= 0)
                {//The block is within 12 pts of hitting another block so guide it in
                    int remainder = 0;
                    remainder = (blockx - Xpos) % 24;

                    if (remainder > 12)
                    {//then go right
                        theShape.magnet = 1;
                    }
                    else
                    {//go left

                        theShape.magnet = -1;
                    }

                }

                //If the current shapes position is outside of the top of the playing area, then
                //indicate that the game is over

                if ((bPlayfield[theShape.PositionX + theShape.CurrentShape[theShape.Rotation, aBlock, 0], theShape.PositionY + theShape.CurrentShape[theShape.Rotation, aBlock, 1]].getTypeInt() >= 0))
                {
                  return true;
                }
            }
            return false;
        }
コード例 #6
0
ファイル: ParticleScreen.cs プロジェクト: hillgr/rotatetris
        /// <summary>
        /// Constructor.
        /// </summary>
        public ParticleScreen()
        {
            TransitionOnTime = TimeSpan.FromSeconds(1.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            mCurrentShape = new Shape(mPlayfield,true);
            mNextShape = new Shape(mPlayfield,true);
        }
コード例 #7
0
ファイル: Player.cs プロジェクト: hillgr/rotatetris
        public void CreateNewShape()
        {
            //mCurrentShape.Type = mNextShape.Type;
            //for (int i = 0; i < mCurrentShape.mNumberOfBlocks; i++)
               // mCurrentShape.Blocks[i] = mNextShape.Blocks[i];
            //Copy the next shape to the current
            mCurrentShape = new Shape(mPlayfield, linkedblocks);
            mCurrentShape.copy(mNextShape);

            //Set the starting position  in the play area
              //  mCurrentShape.DrawPositionY = mPlayfield.Ypos;
               // mCurrentShape.DrawPositionX = mPlayfield.Xpos + 24 * (mPlayfield.Width / 2);

            //Create a new shape for the nextshape
            mNextShape = new Shape(mPlayfield, linkedblocks);
            mNextShape.Type = ((Shape.ShapeType)(RandomNumber(0, 6)));

            //rotation to zero?
            mCurrentShape.Rotation = 0;
        }
コード例 #8
0
ファイル: Player.cs プロジェクト: hillgr/rotatetris
        public void startnewgame()
        {
            mCurrentShape = new Shape(mPlayfield, linkedblocks);
            mNextShape = new Shape(mPlayfield, linkedblocks);

            mNextShape.Type = ((Shape.ShapeType)(RandomNumber(0, 6)));
            mCurrentShape.Type = ((Shape.ShapeType)(RandomNumber(0, 6)));
            mPlayfield.ClearPlayfield();
            mScore = 0;

            //mNumberOfLinesCleared = 0;
            mTotalLines = 0;
            mLevel = 0;
        }