From f06e8c29456d4f96395e397171dd37ef81b39cc0 Mon Sep 17 00:00:00 2001
From: Nepenthe <3368357411@qq.com>
Date: Thu, 31 Aug 2023 20:47:04 +0800
Subject: [PATCH] add button to start game
---
TinyMatchGame/MainWindow.xaml | 3 ++-
TinyMatchGame/MainWindow.xaml.cs | 21 ++++++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/TinyMatchGame/MainWindow.xaml b/TinyMatchGame/MainWindow.xaml
index 6eba7b2..6b59fbb 100644
--- a/TinyMatchGame/MainWindow.xaml
+++ b/TinyMatchGame/MainWindow.xaml
@@ -36,6 +36,7 @@
-
+
+
diff --git a/TinyMatchGame/MainWindow.xaml.cs b/TinyMatchGame/MainWindow.xaml.cs
index 8e2703f..d314ed6 100644
--- a/TinyMatchGame/MainWindow.xaml.cs
+++ b/TinyMatchGame/MainWindow.xaml.cs
@@ -25,6 +25,7 @@ public partial class MainWindow : Window
DispatcherTimer timer = new DispatcherTimer();
int tenthsOfSecondsElapsed;
int matchesFound;
+ bool whetherStart = false;
public MainWindow()
{
InitializeComponent();
@@ -72,11 +73,14 @@ private void SetUpGame()
interestingEmoji.RemoveAt(index);
}
}
-
- // start the timer and reset the variables
- timer.Start();
- tenthsOfSecondsElapsed = 0;
- matchesFound = 0;
+ if (whetherStart)
+ {
+ // start the timer and reset the variables
+ timer.Start();
+ tenthsOfSecondsElapsed = 0;
+ matchesFound = 0;
+ }
+
}
TextBlock lastTextBlockClicked;
@@ -111,5 +115,12 @@ private void InfoTextBlock_MouseBlock(object sender, MouseButtonEventArgs e)
SetUpGame();
}
}
+
+ private void StartGameButton_Click(object sender, RoutedEventArgs e)
+ {
+ whetherStart = true;
+ startButton.Visibility = Visibility.Collapsed;
+ timer.Start();
+ }
}
}