Exemplo n.º 1
0
        /// <summary>
        /// Respond to the user input -- with requests affecting myGame
        /// </summary>
        /// <param name="myGame">The game object to update in response to events.</param>
        private static void HandleUserInput(Snap myGame)
        {
            //Fetch the next batch of UI interaction
            SwinGame.ProcessEvents();

            if (SwinGame.KeyTyped (KeyCode.vk_SPACE))
            {
                myGame.FlipNextCard ();
            }

            if (myGame.IsStarted)
            {
                if ( SwinGame.KeyTyped (KeyCode.vk_LSHIFT) &&
                    SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
            {
            //TODO: add sound effects
            }
            else if (SwinGame.KeyTyped (KeyCode.vk_LSHIFT))
            {
            myGame.PlayerHit (0);
            }
            else if (SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
            {
                myGame.PlayerHit (1);
            }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draws the game to the Window.
        /// </summary>
        /// <param name="myGame">The details of the game -- mostly top card and scores.</param>
        private static void DrawGame(Snap myGame)
        {
            SwinGame.DrawBitmap("cardsBoard.png",0, 0);

            // Draw the top card
            Card top = myGame.TopCard;
            if (top != null)
            {

                SwinGame.DrawText ("Top Card is " + top.ToString (), Color.RoyalBlue, 0, 20);
                SwinGame.DrawText ("Player 1 score: " + myGame.Score(0), Color.RoyalBlue, 0, 30);
                SwinGame.DrawText ("Player 2 score: " + myGame.Score(1), Color.RoyalBlue, 0, 40);
                SwinGame.DrawCell (SwinGame.BitmapNamed ("Cards"), top.CardIndex, 521, 153);
                SwinGame.DrawText (""+ myGame.Score(0), Color.White,"GameFont",0,30);
            }
            else
            {
                SwinGame.DrawText ("No card played yet...", Color.RoyalBlue, 0, 20);
            }

            // Draw the back of the cards... to represent the deck
            SwinGame.DrawCell (SwinGame.BitmapNamed ("Cards"), 52, 155, 153);

            //Draw onto the screen
            SwinGame.RefreshScreen(60);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Respond to the user input -- with requests affecting myGame
        /// </summary>
        /// <param name="myGame">The game object to update in response to events.</param>
        private static void HandleUserInput(Snap myGame)
        {
            //Fetch the next batch of UI interaction
            SwinGame.ProcessEvents();

            if (SwinGame.KeyTyped (KeyCode.vk_SPACE))
            {
                myGame.Start ();
            }
            if(myGame.IsStarted)
            {
                if(SwinGame.KeyTyped (KeyCode.vk_LSHIFT) &&SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
                {
                    SwinGame.PlaySoundEffect ("Slap");
                }
                else if(SwinGame.KeyTyped (KeyCode.vk_LSHIFT))
                {
                    myGame.PlayerHit (0);
                }
                else if (SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
                {
                    myGame.PlayerHit (1);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Respond to the user input -- with requests affecting myGame
        /// </summary>
        /// <param name="myGame">The game object to update in response to events.</param>
        private static void HandleUserInput(Snap myGame)
        {
            //Fetch the next batch of UI interaction
            SwinGame.ProcessEvents();

            if (SwinGame.KeyTyped (KeyCode.vk_SPACE))
            {
                myGame.Start ();
            }

            if (myGame.IsStarted)
            {
                if ( SwinGame.KeyTyped (KeyCode.vk_LSHIFT) &&
                    SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
                {
                    //TODO: add sound effects
                    SwinGame.LoadSoundEffectNamed("Buzz","Buzz.wav");
                    SwinGame.PlaySoundEffect("Buzz");
                }
                else if (SwinGame.KeyTyped (KeyCode.vk_LSHIFT))
                {
                    myGame.PlayerHit (0);
                    SwinGame.LoadSoundEffectNamed("Slap","Slap.wav");
                    SwinGame.PlaySoundEffect("Slap");
                }
                else if (SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
                {
                    myGame.PlayerHit (1);
                    SwinGame.LoadSoundEffectNamed("Slap2","Slap2.wav");
                    SwinGame.PlaySoundEffect("Slap2");
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Respond to the user input -- with requests affecting myGame
        /// </summary>
        /// <param name="myGame">The game object to update in response to events.</param>
        private static void HandleUserInput(Snap myGame)
        {
            //Fetch the next batch of UI interaction
            SwinGame.ProcessEvents();

            if (SwinGame.KeyTyped (KeyCode.vk_SPACE))
            {
                myGame.Start ();
            }
            <<<<<<< HEAD

            =======

            if (myGame.IsStarted)
            {
                if (SwinGame.KeyTyped (KeyCode.vk_LSHIFT) &&
                    SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
                {
                    //Insert sound here
                    //Personal note: Pretty sure sound here will never play unless both
                }
                else if (SwinGame.KeyTyped (KeyCode.vk_LSHIFT))
                {
                    myGame.PlayerHit (0);
                }
                else if (SwinGame.KeyTyped (KeyCode.vk_RSHIFT))
                {
                    myGame.PlayerHit (1);
                }
            }

            >>>>>>> add-player-hit
        }
Exemplo n.º 6
0
        /// <summary>
        /// Respond to the user input -- with requests affecting myGame
        /// </summary>
        /// <param name="myGame">The game object to update in response to events.</param>
        private static void HandleUserInput(Snap myGame)
        {
            //Fetch the next batch of UI interaction
            SwinGame.ProcessEvents();

            if (SwinGame.KeyTyped (KeyCode.vk_SPACE))
            {
                myGame.Start ();
            }
        }
Exemplo n.º 7
0
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("Snap!", 860, 500);

            //Load the card images and set their cell details
            LoadResources();

            // Create the game!
            Snap myGame = new Snap ();

            //Run the game loop
            while(false == SwinGame.WindowCloseRequested())
            {
                HandleUserInput (myGame);
                DrawGame (myGame);
                UpdateGame (myGame);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Updates the game -- it should flip the cards itself once started!
 /// </summary>
 /// <param name="myGame">The game to be updated...</param>
 private static void UpdateGame(Snap myGame)
 {
     myGame.Update(); // just ask the game to do this...
 }
Exemplo n.º 9
0
            public void TestSnapCreation()
            {
                Snap s = new Snap();

                Assert.IsTrue(s.CardsRemain);
                Assert.IsNull (s.TopCard);
            }
Exemplo n.º 10
0
            public void TestFlipNextCard()
            {
                Snap s = new Snap();

                Assert.IsTrue(s.CardsRemain);
                Assert.IsNull (s.TopCard);

                s.FlipNextCard ();

                Assert.IsNull (s._topCards [0]);
                Assert.IsNotNull (s._topCards [1]);
            }
Exemplo n.º 11
0
 /// <summary>
 /// Draws the game to the Window.
 /// </summary>
 /// <param name="myGame">The details of the game -- mostly top card and scores.</param>
 private static void DrawGame(Snap myGame)
 {
Exemplo n.º 12
0
 //shuffle
 private static void Sheffle(Snap myGame)
 {
 myGame.shuffle(); // just ask the game to do this...
 }