diff --git a/src/GameLogic/Deck.cs b/src/GameLogic/Deck.cs index 4b30d8f89..ebbd08ad2 100644 --- a/src/GameLogic/Deck.cs +++ b/src/GameLogic/Deck.cs @@ -55,6 +55,23 @@ public int CardsRemaining public void Shuffle() { //TODO: implement shuffle! + for(int i =0; i < 52; i++) + { + if(_cards[i].FaceUp) _cards[i].TurnOver(); + } + Random rnd = new Random(); + + //for each card (no need to shuffle last card) + for(int i = 0; i < 52 - 1; i++); + { + //pick a random index + int rndIdx = rnd.Next(52 - i); + + Card temp = _cards[i]; + _cards[i] = _cards[i + rndIdx]; + _cards[i + rndIdx] = temp; + } + _topCard = 0; } /// diff --git a/src/GameLogic/Snap.cs b/src/GameLogic/Snap.cs index 42894a1a7..af89d3f79 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,11 @@ public void FlipNextCard() public void Update() { //TODO: implement update to automatically slip cards! + if (_gameTimer.Ticks > _flipTime) + { + _gameTimer.Reset (); + FlipNextCard (); + } } /// diff --git a/src/SnapGame.cs b/src/SnapGame.cs index ec78e9072..c9b42b12a 100644 --- a/src/SnapGame.cs +++ b/src/SnapGame.cs @@ -26,6 +26,22 @@ private static void HandleUserInput(Snap myGame) { 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); + } + } } ///