Skip to content

Commit

Permalink
add button to start game
Browse files Browse the repository at this point in the history
  • Loading branch information
theNefelibatas committed Aug 31, 2023
1 parent c53d438 commit f06e8c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion TinyMatchGame/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<TextBlock Grid.Row="3" Grid.Column="1" Text="?" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="36" MouseDown="TextBlock_MouseDown"/>
<TextBlock Grid.Row="3" Grid.Column="2" Text="?" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="36" MouseDown="TextBlock_MouseDown"/>
<TextBlock Grid.Row="3" Grid.Column="3" Text="?" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="36" MouseDown="TextBlock_MouseDown"/>
<TextBlock x:Name="infoTextBlock" HorizontalAlignment="Center" Grid.Row="4" TextWrapping="Wrap" Text="Information TextBlock" VerticalAlignment="Center" Grid.ColumnSpan="4" FontSize="36" MouseDown="InfoTextBlock_MouseBlock"/>
<TextBlock x:Name="infoTextBlock" HorizontalAlignment="Center" Grid.Row="4" TextWrapping="Wrap" Text="" VerticalAlignment="Center" Grid.ColumnSpan="4" FontSize="36" MouseDown="InfoTextBlock_MouseBlock"/>
<Button x:Name="startButton" Grid.Column="1" Content="Start Play" HorizontalAlignment="Center" Grid.Row="4" VerticalAlignment="Center" Click="StartGameButton_Click" Grid.ColumnSpan="2" FontSize="36"/>
</Grid>
</Window>
21 changes: 16 additions & 5 deletions TinyMatchGame/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class MainWindow : Window
DispatcherTimer timer = new DispatcherTimer();
int tenthsOfSecondsElapsed;
int matchesFound;
bool whetherStart = false;
public MainWindow()
{
InitializeComponent();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit f06e8c2

Please sign in to comment.