Exemplo n.º 1
0
        void itemmove(List <baritem> it)
        {
            for (int i = 0; i < it.Count; i++)
            {
                if (!(it.ElementAt(i).item.Location.X < 0 && it.ElementAt(i).item.Location.Y < 0))
                {
                    it.ElementAt(i).item.Location = new Point(it.ElementAt(i).item.Location.X, it.ElementAt(i).item.Location.Y + 2);
                }
                //if ((it.ElementAt(i).item.Location.X < label8.Location.X + label8.Width) && (label8.Location.X < it.ElementAt(i).item.Location.X + it.ElementAt(i).item.Width) && (it.ElementAt(i).item.Height + it.ElementAt(i).item.Location.Y < label8.Location.Y) && (it.ElementAt(i).item.Height + it.ElementAt(i).item.Location.Y > label8.Location.Y + label8.Height))
                if ((label8.Location.X < it.ElementAt(i).item.Location.X + it.ElementAt(i).item.Width) && (it.ElementAt(i).item.Location.X < label8.Location.X + label8.Width) && (it.ElementAt(i).item.Location.Y + it.ElementAt(i).item.Width > label8.Location.Y - 2) && (it.ElementAt(i).item.Location.Y + it.ElementAt(i).item.Width < label8.Location.Y + 2))
                {
                    //효과
                    if (it.ElementAt(i).itemnum == 1)
                    {
                        label8.Width = 110; timerforitem1 = 0; label24.Visible = true; label24.Text = "long bar!"; timer4.Enabled = true;
                    }
                    if (it.ElementAt(i).itemnum == 2)
                    {
                        ballnum++; sball ww = new sball(); ww.ball.Location = new Point(label8.Location.X + 20, label8.Location.Y - 16); panel3.Controls.Add(ww.ball); serveball.Add(ww); serveball.Last().ball.BringToFront();
                    }
                    if (it.ElementAt(i).itemnum == 3)
                    {
                        ballspeed = 3; timerforitem2 = 0; label25.Visible = true; label25.Text = "slooow"; timer5.Enabled = true;
                    }



                    it.ElementAt(i).item.Location = new Point(-22, -22);
                    it.ElementAt(i).item.Visible  = false;
                }
                if (it.ElementAt(i).item.Location.Y > panel3.Height)
                {
                    it.ElementAt(i).item.Location = new Point(-22, -22);
                    it.ElementAt(i).item.Visible  = false;
                }
            }

            /* for (int i = 0; i < it.Count; i++)
             * {   if(it.ElementAt(i).item.Visible==false)
             *   it.RemoveAt(i); i--;
             * }*/
        }
Exemplo n.º 2
0
        void serveballmove(sball ball)
        {
            //충격 딜레이



            double kk = DegreeToRadian(ball.k);
            double rx = Math.Cos(kk) * ballspeed;
            double ry = Math.Sin(kk) * ballspeed;

            if (!(ball.ball.Location.X < 0 && ball.ball.Location.Y < 0))
            {
                ball.ball.Location = new Point(ball.ball.Location.X + (int)rx, ball.ball.Location.Y - (int)ry);
            }
            rx = ball.ball.Location.X;
            ry = ball.ball.Location.Y;
            //foreach (Label n in blocksLabel)
            // 서브 볼 벽돌 충돌
            for (int i = 0; i < blocksLabel.Count; i++)
            {
                double buffangle = ball.k;
                double nx        = blocksLabel.ElementAt(i).Location.X;
                double ny        = blocksLabel.ElementAt(i).Location.Y;
                if ((nx < rx + ball.ball.Width) && (rx < nx + blocksLabel.ElementAt(i).Width))
                {
                    if ((ry + ball.ball.Height < ny + 2) && (ry + ball.ball.Height > ny - 2) || (ry < ny + 2 + blocksLabel.ElementAt(i).Height) && (ry > ny - 2 + blocksLabel.ElementAt(i).Height))
                    {
                        itemcreate(blocksLabel.ElementAt(i));
                        buffangle = 360 - buffangle;
                        //i = blocksLabel.Count + 1;
                        blocksLabel.ElementAt(i).Visible  = false;
                        blocksLabel.ElementAt(i).Location = new Point(-22, -22);
                        //endscore += 100;
                        // blocksLabel.RemoveAt(i);
                        //  blockstack--;
                    }
                }

                //  if ((ry + ball.ball.Height > ny) && (ry < ny + blocksLabel.ElementAt(i).Height))
                if (((ry > ny) && (ry < ny + blocksLabel.ElementAt(i).Height)) || ((ry + label14.Height > ny) && (ry + label14.Height < ny + blocksLabel.ElementAt(i).Height)))
                {
                    //if ((rx + ball.ball.Width < nx + 2) && (rx + ball.ball.Width > nx - 2) || (nx + blocksLabel.ElementAt(i).Width - 2 < rx) && (nx + blocksLabel.ElementAt(i).Width + 2 > rx))
                    if (((rx < nx) && (rx + label14.Width > nx - 3)) || (rx + label14.Width > blocksLabel.ElementAt(i).Width + blocksLabel.ElementAt(i).Location.X) && (rx < blocksLabel.ElementAt(i).Width + nx + 3))
                    {
                        buffangle = 180 - buffangle;
                        itemcreate(blocksLabel.ElementAt(i));
                        // i = blocksLabel.Count + 1;
                        blocksLabel.ElementAt(i).Visible  = false;
                        blocksLabel.ElementAt(i).Location = new Point(-22, -22);
                        //blocksLabel.RemoveAt(i);
                        // blockstack--;
                        //endscore += 100;
                    }
                }

                if (buffangle < 0)
                {
                    buffangle += 360;
                }
                if (buffangle > 360)
                {
                    buffangle -= 360;
                }
                ball.k = buffangle;
            }
            // 서브 볼



            ///
            //바 충돌 윗면
            //
            //label15.Text = "검사";
            if ((label8.Location.X < ball.ball.Location.X + ball.ball.Width) && (ball.ball.Location.X < label8.Location.X + label8.Width) && (ball.ball.Location.Y + ball.ball.Width > label8.Location.Y - 2) && (ball.ball.Location.Y + ball.ball.Width < label8.Location.Y + 2))
            {
                double buffangle = ball.k;
                buffangle = 360 - buffangle;
                if (buffangle < 0)
                {
                    buffangle += 360;
                }
                if (buffangle > 360)
                {
                    buffangle -= 360;
                }

                ball.k = buffangle;
            }
            //벽면 충돌
            if (ball.ball.Location.Y < 1)
            {
                double buffangle = ball.k;
                buffangle = 360 - buffangle;
                if (buffangle < 0)
                {
                    buffangle += 360;
                }
                if (buffangle > 360)
                {
                    buffangle -= 360;
                }
                ball.ball.Location = new Point(ball.ball.Location.X, ball.ball.Location.Y + 2);
                ball.k             = buffangle;
            }
            if ((ball.ball.Location.X < 1) || (ball.ball.Location.X + ball.ball.Width > panel3.Width))
            {
                double buffangle = ball.k;
                buffangle = 180 - buffangle;

                if (buffangle < 0)
                {
                    buffangle += 360;
                }
                if (buffangle > 360)
                {
                    buffangle -= 360;
                }
                if (ball.ball.Location.X < 1)
                {
                    ball.ball.Location = new Point(ball.ball.Location.X + 2, ball.ball.Location.Y);
                }
                else
                {
                    ball.ball.Location = new Point(ball.ball.Location.X - 2, ball.ball.Location.Y);
                }
                ball.k = buffangle;
            }
            if (ball.ball.Location.Y + 5 > panel3.Height)
            {
                //서브 공 탈락
                ball.ball.Location = new Point(-22, -22);
                ball.ball.Visible  = false;
                //ballnum--;
            }
        }