コード例 #1
0
ファイル: SnapGame.cs プロジェクト: thomasklash/QuickSnap
        /// <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);
            }
            }
        }
コード例 #2
0
ファイル: SnapGame.cs プロジェクト: woichong/QuickSnap
        /// <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);
        }
コード例 #3
0
ファイル: SnapGame.cs プロジェクト: 9983341/QuickSnap
        /// <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);
                }
            }
        }
コード例 #4
0
ファイル: SnapGame.cs プロジェクト: cngu8904/QuickSnap
        /// <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");
                }
            }
        }
コード例 #5
0
ファイル: SnapGame.cs プロジェクト: Gemore/QuickSnap
        /// <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
        }
コード例 #6
0
ファイル: SnapGame.cs プロジェクト: akmaltt/QuickSnap
        /// <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 ();
            }
        }
コード例 #7
0
ファイル: SnapGame.cs プロジェクト: thomasklash/QuickSnap
        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);
            }
        }
コード例 #8
0
ファイル: SnapGame.cs プロジェクト: thomasklash/QuickSnap
 /// <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...
 }
コード例 #9
0
ファイル: Snap.cs プロジェクト: jack101989/QuickSnap
            public void TestSnapCreation()
            {
                Snap s = new Snap();

                Assert.IsTrue(s.CardsRemain);
                Assert.IsNull (s.TopCard);
            }
コード例 #10
0
ファイル: Snap.cs プロジェクト: jack101989/QuickSnap
            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]);
            }
コード例 #11
0
ファイル: SnapGame.cs プロジェクト: ZeEskimo/QuickSnap
 /// <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)
 {
コード例 #12
0
ファイル: SnapGame.cs プロジェクト: conradhengstler/QuickSnap
 //shuffle
 private static void Sheffle(Snap myGame)
 {
 myGame.shuffle(); // just ask the game to do this...
 }