コード例 #1
0
ファイル: System.cs プロジェクト: DerekAnton/SuperSpeedPong
        // Time Calculation //
        private void updateTimes(GameTime gameTime)
        {
            if (ScoreBoard.gtime >= 0)
            {
                if (!TimeCalculator.hardpaused)
                {
                    ScoreBoard.gtime        = (GAME_LENGTH + lastpausedtime) - getTime(gameTime);
                    hardpausedcalc.lasttime = getTime(gameTime);
                }
                else
                {
                    hardpausedcalc.pausedtime = getTime(gameTime) - hardpausedcalc.lasttime;
                }

                if (TimeCalculator.softpaused)
                {
                    if (getTime(gameTime) - softpausedcalc.lasttime >= 3)
                    {
                        TimeCalculator.softResume();
                    }
                }
                else if (!TimeCalculator.softpaused)
                {
                    softpausedcalc.lasttime = getTime(gameTime);
                }
                else
                {
                }
            }
            else
            {
                if (RScore.score > LScore.score)
                {
                    RScore.incrementRGames();
                }
                else if (LScore.score > RScore.score)
                {
                    LScore.incrementLGames();
                }
                else if (LScore.score == RScore.score)
                {
                    LScore.incrementLGames();
                    RScore.incrementRGames();
                }
                else
                {
                }

                resetValues(gameTime);
                TimeCalculator.softPause();
            }
        }
コード例 #2
0
ファイル: Ball.cs プロジェクト: DerekAnton/SuperSpeedPong
        // Angular Collision Logic. Passed An Enumerator That Denotes What Critical Area Was Hit (Either A Wall, Paddle, Or Score Zone) //
        private void changeAngle(int condition)
        {
            if (condition == (int)Intersection.Left)
            {
                Jukebox.playScore();
                RScore.incrementRScore();
                ballmovespeed = 200;
                this.setVector(new Vector2(320, 240));

                if (!TimeCalculator.softpaused)
                {
                    TimeCalculator.softPause();
                }
            }
            else if (condition == (int)Intersection.Right)
            {
                Jukebox.playScore();
                LScore.incrementLScore();
                ballmovespeed = 200;
                this.setVector(new Vector2(320, 240));

                if (!TimeCalculator.softpaused)
                {
                    TimeCalculator.softPause();
                }
            }
            else if (condition == (int)Intersection.Top)
            {
                Jukebox.playWallHit();
                if (lastX - position.X < 0)
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.UpLeft;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.DownRight;
                    }
                }
                else
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.UpRight;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.DownLeft;
                    }
                }
            }
            else if (condition == (int)Intersection.Bot)
            {
                Jukebox.playWallHit();
                if (lastX - position.X < 0)
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.UpRight;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.DownLeft;
                    }
                }
                else
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.UpLeft;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.UpLeft;
                    }
                }
            }
            else if (condition == (int)Intersection.LeftPaddle)
            {
                Jukebox.playPaddleHit();
                if (lastX - position.X < 0)
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.DownLeft;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.UpLeft;
                    }
                }
                else
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.DownRight;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.UpRight;
                    }
                }

                increaseSpeed();
            }
            else if (condition == (int)Intersection.RightPaddle)
            {
                Jukebox.playPaddleHit();
                if (lastX - position.X < 0)
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.DownLeft;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.UpLeft;
                    }
                }
                else
                {
                    if (lastY - position.Y < 0)
                    {
                        diagonal = (int)Diagonal.UpRight;
                    }
                    else
                    {
                        diagonal = (int)Diagonal.DownRight;
                    }
                }

                increaseSpeed();
            }
            else
            {
            }
        }