diff --git a/src/GameLogic/Snap.cs b/src/GameLogic/Snap.cs index 42894a1a7..625db455c 100644 --- a/src/GameLogic/Snap.cs +++ b/src/GameLogic/Snap.cs @@ -37,6 +37,7 @@ public class Snap public Snap () { _deck = new Deck (); + _gameTimer = SwinGame.CreateTimer (); } /// @@ -92,6 +93,7 @@ public void Start() _deck.Shuffle (); // Return the cards and shuffle FlipNextCard (); // Flip the first card... + _gameTimer.Start(); } } @@ -112,6 +114,13 @@ public void FlipNextCard() public void Update() { //TODO: implement update to automatically slip cards! + + if (_gameTimer.Ticks > _flipTime) + { + _gameTimer.Reset (); + FlipNextCard (); + } + } /// @@ -143,6 +152,7 @@ public void PlayerHit (int player) // stop the game... _started = false; + _gameTimer.Stop (); } #region Snap Game Unit Tests diff --git a/src/SnapGame.cs b/src/SnapGame.cs index ec78e9072..4b85f27e0 100644 --- a/src/SnapGame.cs +++ b/src/SnapGame.cs @@ -12,26 +12,6 @@ public static void LoadResources() cards = SwinGame.LoadBitmapNamed ("Cards", "Cards.png"); SwinGame.BitmapSetCellDetails (cards, 82, 110, 13, 5, 53); // set the cells in the bitmap to match the cards } - - /// - /// Respond to the user input -- with requests affecting myGame - /// - /// The game object to update in response to events. - private static void HandleUserInput(Snap myGame) - { - //Fetch the next batch of UI interaction - SwinGame.ProcessEvents(); - - if (SwinGame.KeyTyped (KeyCode.vk_SPACE)) - { - myGame.FlipNextCard (); - } - } - - /// - /// Draws the game to the Window. - /// - /// The details of the game -- mostly top card and scores. private static void DrawGame(Snap myGame) { SwinGame.ClearScreen(Color.White); @@ -56,6 +36,28 @@ private static void DrawGame(Snap myGame) //Draw onto the screen SwinGame.RefreshScreen(60); } + + + /// + /// Respond to the user input -- with requests affecting myGame + /// + /// The game object to update in response to events. + private static void HandleUserInput(Snap myGame) + { + //Fetch the next batch of UI interaction + SwinGame.ProcessEvents(); + + if (SwinGame.KeyTyped (KeyCode.vk_SPACE)) + { + myGame.Start (); + } + } + + /// + /// Draws the game to the Window. + /// + /// The details of the game -- mostly top card and scores. + /// /// Updates the game -- it should flip the cards itself once started!