public void Update() { if (Collided(mTargetBlock)) { VectorComponents currentV = new VectorComponents(); currentV.Update(Center, Center + Velocity, mTargetBlock.FrontDirection); Vector2 newVelocity = currentV.TangentVector() - currentV.NormalVector(); XNACS1Rectangle reflectV = new XNACS1Rectangle(); reflectV.SetEndPoints(Center, Center + (newVelocity * kDrawSize), 0.3f); reflectV.Color = Color.DeepPink; mShowVecs.Add(currentV); mReflection.Add(reflectV); Velocity = newVelocity; } else { XNACS1Lib.BoundCollideStatus status = XNACS1Base.World.ClampAtWorldBound(this); switch (status) { case BoundCollideStatus.CollideBottom: case BoundCollideStatus.CollideTop: VelocityY = -VelocityY; break; case BoundCollideStatus.CollideLeft: case BoundCollideStatus.CollideRight: VelocityX = -VelocityX; break; } } }
protected override void InitializeWorld() { World.SetWorldCoordinate(Vector2.Zero, kWorldSize); DefineGrid(); mBlock = new MyBlock(); mBall = new MySoccer(); mShowVecA = new VectorComponents(); mShowVecA.HideVectorComponents(); mShowVecB = new VectorComponents(); mShowVecB.HideVectorComponents(); }