This is the main type for your game
Inheritance: Microsoft.Xna.Framework.Game
Esempio n. 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (HopnetGame game = new HopnetGame())
     {
         game.Run();
     }
 }
Esempio n. 2
0
        public DrawGameOver(HopnetGame hopNetGame, SpriteBatch sBatch, int score)
        {
            hopnetGame = hopNetGame;
            spriteBatch = sBatch;
            achievedScore = score;
            scale = 1;

            cursorPosition = new Vector2(GameConstants.DrawGameOverScorePosition.X - (int)(2*GameConstants.DrawHighScoreCharWidth*(scale/0.5)),GameConstants.DrawGameOverScorePosition.Y);
        }
Esempio n. 3
0
        public MainMenu(HopnetGame hopnetGame)
        {
            highScores = new HighScores();
            highScores.Load();
            buttonTimeoutStopwatch = new Stopwatch();
            buttonTimeoutStopwatch.Reset();

            hopNetGame = hopnetGame;
            handTextureType = new int[2];
            handTextureType[(int)GameConstants.Hand.Left] = (int)GameConstants.TextureType.Normal;
            handTextureType[(int)GameConstants.Hand.Right] = (int)GameConstants.TextureType.Normal;

            cursorOnButtonState = new bool[2];

            kinectHandPosition = new Vector2[2];
            kinectHandPosition[(int)GameConstants.Hand.Left] = Vector2.Zero;
            kinectHandPosition[(int)GameConstants.Hand.Right] = Vector2.Zero;

            timerStepSizePerSecond = GameConstants.HorizontalGameResolution / GameConstants.ButtonTimeDelayInSeconds;
            hScale = (GameConstants.HorizontalGameResolution/ GameConstants.DefaultHorizontalResolutionToScaleInto);
            vScale = (GameConstants.VerticalGameResolution / GameConstants.DefaultVerticalResolutionToScaleInto);

            backgroundSprite = new Sprite();
            gameLostSprite = new Sprite();
            timeoutProgressBar = new Sprite { rectangle = new Rectangle(0, 0, 0, GameConstants.VerticalGameResolution/80) };
            newGameSprite = new Sprite[GameConstants.MenuTextureNumber];
            scoresSprite = new Sprite[GameConstants.MenuTextureNumber];
            goBackSprite = new Sprite[GameConstants.MenuTextureNumber];
            exitSprite = new Sprite[GameConstants.MenuTextureNumber];
            easyDifficulty = new Sprite[GameConstants.MenuTextureNumber];
            mediumDifficulty = new Sprite[GameConstants.MenuTextureNumber];
            hardDifficulty = new Sprite[GameConstants.MenuTextureNumber];
            confirmExit = new Sprite[GameConstants.MenuTextureNumber];
            handSprite = new Sprite[2, GameConstants.MenuTextureNumber];
            tryAgainSprite = new Sprite[GameConstants.MenuTextureNumber];

            #region initialization of every sprite's properties
            for (int i = 0; i < GameConstants.MenuTextureNumber; i++)
            {
                confirmExit[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution / 2 - GameConstants.DefaultMenuBtnWidth * hScale / 2),
                        (int)(GameConstants.VerticalGameResolution / 2 - GameConstants.DefaultMenuBtnHeight * vScale / 2),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale), (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };


                tryAgainSprite[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                                                (int)(GameConstants.HorizontalGameResolution/2 -GameConstants.DefaultMenuBtnWidth*hScale/2),
                                                (int)(GameConstants.VerticalGameResolution/2 -GameConstants.DefaultMenuBtnHeight*vScale/2),
                                                (int) (GameConstants.DefaultMenuBtnWidth*hScale),
                                                (int) (GameConstants.DefaultMenuBtnHeight*vScale))
                };



                goBackSprite[i] = new Sprite
                {
                    Rectangle = new Rectangle((int)(GameConstants.HorizontalGameResolution * 0.15f - GameConstants.DefaultMenuBtnWidth * hScale / 2),
                                              (int)(7 * GameConstants.VerticalGameResolution / 8 - GameConstants.DefaultMenuBtnHeight * vScale / 2),
                                              (int)(GameConstants.DefaultMenuBtnWidth  * hScale),
                                              (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };

                easyDifficulty[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution * 0.5f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)),
                        (int)(GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale),
                        (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };

                mediumDifficulty[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution * 0.5f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)),
                        (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale),
                        (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };

                hardDifficulty[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution * 0.5f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)),
                        (int)(7*GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale),
                        (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };

                handSprite[(int)GameConstants.Hand.Left, i] = new Sprite();
                handSprite[(int)GameConstants.Hand.Right, i] = new Sprite();

                handSprite[(int)GameConstants.Hand.Left, i].Position = new Vector2(GameConstants.HorizontalGameResolution / 2, GameConstants.VerticalGameResolution / 2);
                handSprite[(int)GameConstants.Hand.Right, i].Position = new Vector2(GameConstants.HorizontalGameResolution / 2, GameConstants.VerticalGameResolution / 2);

                handSprite[(int)GameConstants.Hand.Left, i].Rectangle = new Rectangle((int)(GameConstants.HorizontalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * hScale),
                    (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * vScale), (int)(GameConstants.HandCursorRadius * hScale), (int)(GameConstants.HandCursorRadius * vScale));

                handSprite[(int)GameConstants.Hand.Right, i].Rectangle = new Rectangle((int)(GameConstants.HorizontalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * hScale),
                    (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.HandCursorRadius / 2) * vScale), (int)(GameConstants.HandCursorRadius * hScale), (int)(GameConstants.HandCursorRadius * vScale));

                newGameSprite[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution * 0.15f - (GameConstants.DefaultMenuBtnWidth * hScale/2)),
                        (int)(2*GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale),
                        (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };

                scoresSprite[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution * 0.15f - (GameConstants.DefaultMenuBtnWidth * hScale / 2)),
                        (int)(GameConstants.VerticalGameResolution / 2 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale),
                        (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };

                exitSprite[i] = new Sprite
                {
                    Rectangle = new Rectangle(
                        (int)(GameConstants.HorizontalGameResolution * 0.15f- (GameConstants.DefaultMenuBtnWidth * hScale/2)),
                        (int)(6 * GameConstants.VerticalGameResolution / 8 - (GameConstants.DefaultMenuBtnHeight * vScale / 2)),
                        (int)(GameConstants.DefaultMenuBtnWidth * hScale), 
                        (int)(GameConstants.DefaultMenuBtnHeight * vScale))
                };
            }
            backgroundSprite.Rectangle = new Rectangle(0, 0, GameConstants.HorizontalGameResolution, GameConstants.VerticalGameResolution);
            gameLostSprite.Rectangle = new Rectangle(GameConstants.HorizontalGameResolution/2- (int)(1.5f*hScale* GameConstants.DefaultMenuBtnWidth/2), 2*GameConstants.VerticalGameResolution/8 - (int)(vScale* GameConstants.DefaultMenuBtnHeight/2), (int)(GameConstants.DefaultMenuBtnWidth*hScale*1.5f), (int)(vScale* GameConstants.DefaultMenuBtnHeight));

            #endregion
        }