protected void LegsHandleBeforeStep() { float legLeftCoef = AngleConversion.RadianToDegree(this.legLeft.Rotation) > -2 ? 1 : (float)System.Math.Pow(System.Math.Sin(AngleConversion.DegreeToRadian(92) + this.legLeft.Rotation), 15), legRightCoef = AngleConversion.RadianToDegree(this.legRight.Rotation) < 2 ? 1 : (float)System.Math.Pow(System.Math.Sin(AngleConversion.DegreeToRadian(92) - this.legRight.Rotation), 15); this.legLeft.ApplyTorque(legLeftCoef); this.legRight.ApplyTorque(-legRightCoef); this.playerLeftSpeeds.BeforeStep = this.playerLeft.LinearVelocity.X; this.playerRightSpeeds.BeforeStep = this.playerRight.LinearVelocity.X; }
private void LegsHandleBeforeStep() { float legLeftCoef = AngleConversion.RadianToDegree(this.legLeft.GetAngle()) > -2 ? 1 : (float)System.Math.Pow(System.Math.Sin(AngleConversion.DegreeToRadian(92) + this.legLeft.GetAngle()), 15), legRightCoef = AngleConversion.RadianToDegree(this.legRight.GetAngle()) < 2 ? 1 : (float)System.Math.Pow(System.Math.Sin(AngleConversion.DegreeToRadian(92) - this.legRight.GetAngle()), 15); this.legLeft.ApplyTorque(1 * legLeftCoef); this.playerLeftSpeeds.BeforeStep = this.playerLeft.GetLinearVelocity().X; float legLeftAngleDegree = AngleConversion.RadianToDegree(this.LegLeftAngle), legRightAngleDegree = AngleConversion.RadianToDegree(this.LegRightAngle); if (legLeftAngleDegree < -9 && legLeftAngleDegree > -12) { this.legRight.ApplyTorque(legRightCoef); } else { this.legRight.ApplyTorque(-legRightCoef); } this.playerRightSpeeds.BeforeStep = this.playerRight.GetLinearVelocity().X; }
public virtual void Draw(RenderWindow window) { this.playerLeft.Position = new Vector2f( this.objectsState.PlayerLeftPosition.X * this.scale - this.playerLeft.TextureRect.Width / 2f, this.objectsState.PlayerLeftPosition.Y * this.scale - 50); this.legLeft.Position = new Vector2f( this.objectsState.LegLeftPosition.X * this.scale - 7 * (float)Cos(this.objectsState.LegLeftAngle) + 16 * (float)Sin(this.objectsState.LegLeftAngle), this.objectsState.LegLeftPosition.Y * this.scale - 16 * (float)Cos(this.objectsState.LegLeftAngle) - 7 * (float)Sin(this.objectsState.LegLeftAngle)); this.playerRight.Position = new Vector2f( this.objectsState.PlayerRightPosition.X * this.scale + this.playerRight.TextureRect.Width / 2f, this.objectsState.PlayerRightPosition.Y * this.scale - 50); this.legRight.Position = new Vector2f( this.objectsState.LegRightPosition.X * this.scale + 7 * (float)Cos(this.objectsState.LegRightAngle) + 16 * (float)Sin(this.objectsState.LegRightAngle), this.objectsState.LegRightPosition.Y * this.scale - 16 * (float)Cos(this.objectsState.LegRightAngle) + 7 * (float)Sin(this.objectsState.LegRightAngle)); this.ball.Rotation = AngleConversion.RadianToDegree(this.objectsState.BallAngle); this.ball.Position = new Vector2f( this.objectsState.BallPosition.X * this.scale - (float)Sqrt(2) * this.ball.TextureRect.Width / 2f * (float)Sin(PI / 4 - this.objectsState.BallAngle), this.objectsState.BallPosition.Y * this.scale - (float)Sqrt(2) * this.ball.TextureRect.Width / 2f * (float)Cos(PI / 4 - this.objectsState.BallAngle)); string remainTimeString = (this.remainTime / 60).ToString().PadLeft(2, '0') + ":" + (this.remainTime % 60).ToString().PadLeft(2, '0'); this.remainTimeText.DisplayedString = remainTimeString; this.remainTimeText.Position = new Vector2f(Major.Width / 2 - this.remainTimeText.GetGlobalBounds().Width / 2, 10); this.scoreText[0].DisplayedString = this.score[0].ToString(); this.scoreText[1].DisplayedString = this.score[1].ToString(); this.scoreText[1].Position = new Vector2f(Major.Width - 20 - this.scoreText[1].GetGlobalBounds().Width, 20); window.Draw(this.background); window.Draw(this.playerLeft); window.Draw(this.legLeft); window.Draw(this.playerRight); window.Draw(this.legRight); window.Draw(this.ball); window.Draw(this.goalLeft); window.Draw(this.goalRight); window.Draw(this.remainTimeText); window.Draw(this.scoreText[0]); window.Draw(this.scoreText[1]); }