public virtual List<Block> PerformFrame(BCBlockGameState ParentGameState,ref List<cBall> ballsadded,ref List<cBall> ballsremove) { PreviousVelocity = Velocity; //returns the blocks that were affected by the frame (changed or moved). //PointF NextPosition = new PointF(Location.X + Velocity.X, Location.Y + Velocity.Y); PointF NextPosition = Location; BCBlockGameState.IncrementLocation(ParentGameState, ref NextPosition, Velocity); //RectangleF NextPositionBorders = new RectangleF(NextPosition.X - Radius, NextPosition.Y - Radius, Radius, Radius); NormalizeSpeed(); if(ballsadded==null) ballsadded = new List<cBall>(); RectangleF rectangleborders = new RectangleF(Location.X-Radius,Location.Y-Radius,Radius*2,Radius*2); PrevLocation=Location; //Location = new PointF(Location.X+Velocity.X,Location.Y+Velocity.Y); Location = NextPosition; TrailData.Enqueue(new TrailItemData(Location,Radius)); while (TrailData.Count > _Trails) TrailData.Dequeue(); BCBlockGameState wholeref = ParentGameState; List<Block> affectedblocks = InvokePerformFrame(this, ParentGameState, ref ballsadded,ref ballsremove); if(affectedblocks==null) affectedblocks = new List<Block>(); if (wholeref != null) { /*if (isTempBall) { for (int i = 0; i < (int)(10 * BCBlockGameState.ParticleGenerationFactor); i++) { ParentGameState.Particles.Add(new FireParticle(this)); } }*/ //check for collision with the walls... Rectangle clientrect = wholeref.GameArea; bool DoEmitSound=false; bool didhit=false; didhit = CheckWallCollision(rectangleborders, clientrect, ref DoEmitSound); //CheckBall.Y + CheckBall.radius >= Paddle.Y And CheckBall.Y - _ //CheckBall.radius < Paddle.Y + Paddle.PHeight Or (((CheckBall.Y - _ //CheckBall.Yspeed + CheckBall.radius) >= Paddle.Y And CheckBall.Y - _ //CheckBall.Yspeed - CheckBall.radius < Paddle.Y + Paddle.PHeight) And _ //Sgn(CheckBall.Yspeed) = 1) if (wholeref.PlayerPaddle != null) { /* if (rectangleborders.IntersectsWith(wholeref.PlayerPaddle.Getrect()) && Math.Sign(Velocity.Y) == 1) // Paddle paddle = wholeref.PlayerPaddle; //if((Location.Y + Radius >= paddle.Position.Y) && (Location.Y - // Radius < paddle.Position.X+paddle.PaddleSize.Width ) || (((Location.Y - Velocity.Y + Radius) >= paddle.Position.Y && // Location.Y - Velocity.Y - Radius < paddle.Position.Y+paddle.PaddleSize.Height) && Math.Sign(Velocity.Y)==1)) // if (Location.Y + Radius >= paddle.Position.Y && (Location.Y - Radius <= (paddle.Position.X + paddle.PaddleSize.Width))) { //the X coordinate checks out here... { wholeref.PlayerPaddle.Impact(wholeref, this); } } * */ wholeref.PlayerPaddle.CheckImpact(wholeref, this, true); } bool HitBottom=false; if (rectangleborders.Bottom > clientrect.Bottom) { didhit = true; HitBottom=true; DoEmitSound=false; } if (didhit) { numImpacts++; switch (invokeHitWall(wholeref, this)) { case HitWallReturnConstants.HitBall_Default: if (HitBottom) { ParentGameState.invokeballhitbottom(this); ParentGameState.Defer(() => ParentGameState.Balls.Remove(this)); } // break; case HitWallReturnConstants.HitBall_Destroy: ParentGameState.invokeballhitbottom(this); ParentGameState.Defer(() => ParentGameState.Balls.Remove(this)); break; case HitWallReturnConstants.HitBall_Preserve: //the ball is preserved... if (HitBottom) { Velocity = new PointF(Velocity.X,-Velocity.Y); Location = new PointF(Location.X,ParentGameState.GameArea.Bottom-Radius); } break; } } // BCBlockGameState.Soundman.PlaySound("bounce", 0.9f); if(DoEmitSound) BCBlockGameState.Soundman.PlaySound(GetWallHitSound(), 0.9f); affectedblocks.AddRange(CheckBlocks(ParentGameState, ref ballsadded, wholeref)); } return affectedblocks; }