Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/GameLogic/Snap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Snap
public Snap ()
{
_deck = new Deck ();
_gameTimer = SwinGame.CreateTimer ();
}

/// <summary>
Expand Down Expand Up @@ -92,6 +93,7 @@ public void Start()
_deck.Shuffle (); // Return the cards and shuffle

FlipNextCard (); // Flip the first card...
_gameTimer.Start();
}
}

Expand All @@ -112,6 +114,13 @@ public void FlipNextCard()
public void Update()
{
//TODO: implement update to automatically slip cards!

if (_gameTimer.Ticks > _flipTime)
{
_gameTimer.Reset ();
FlipNextCard ();
}

}

/// <summary>
Expand Down Expand Up @@ -143,6 +152,7 @@ public void PlayerHit (int player)

// stop the game...
_started = false;
_gameTimer.Stop ();
}

#region Snap Game Unit Tests
Expand Down
42 changes: 22 additions & 20 deletions src/SnapGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/// <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 ();
}
}

/// <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.ClearScreen(Color.White);
Expand All @@ -56,6 +36,28 @@ private static void DrawGame(Snap myGame)
//Draw onto the screen
SwinGame.RefreshScreen(60);
}


/// <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 ();
}
}

/// <summary>
/// Draws the game to the Window.
/// </summary>
/// <param name="myGame">The details of the game -- mostly top card and scores.</param>


/// <summary>
/// Updates the game -- it should flip the cards itself once started!
Expand Down