private void btnStartGame_Click(object sender, RoutedEventArgs e) { if (gameState == GameState.MainScreen) { this.Title = "Rocket Riot"; } gameTimer.Start(); gameState = GameState.InGame; canvas.Children.Remove(btnStartGame); canvas.Children.Remove(btnHighScores); canvas.Children.Remove(btnInstructions); int temp = 1; zapper = new Zapper(temp, canvas); zapper.generate(); }
public MainWindow() { InitializeComponent(); //Conner's stuff btnStartGame.Click += btnStartGame_Click; btnStartGame.Content = "Start Game"; btnStartGame.FontSize = 50; btnStartGame.Background = Brushes.Yellow; Canvas.SetLeft(btnStartGame, 265); Canvas.SetTop(btnStartGame, 50); btnStartGame.BorderThickness = new Thickness(1); btnStartGame.BorderBrush = Brushes.Black; canvas.Children.Add(btnStartGame); btnHighScores.Click += btnHighScores_Click; btnHighScores.Content = "High Scores"; btnHighScores.FontSize = 40; btnHighScores.Background = Brushes.Yellow; Canvas.SetLeft(btnHighScores, 285); Canvas.SetTop(btnHighScores, 125); btnHighScores.BorderThickness = new Thickness(1); btnHighScores.BorderBrush = Brushes.Black; canvas.Children.Add(btnHighScores); lblHighScores.FontSize = 15; //lblHighScores.Background.Opacity = .5; //lblHighScores.Background = Brushes.White; lblHighScores.Background = new SolidColorBrush(Color.FromArgb(125, 255, 255, 255)); lblHighScores.Foreground = Brushes.Black; Canvas.SetLeft(lblHighScores, 350 - lblHighScores.ActualWidth); Canvas.SetTop(lblHighScores, 120 - lblHighScores.ActualHeight); btnBack.Click += btnBack_Click; btnBack.Content = "Back"; btnBack.FontSize = 40; btnBack.Background = Brushes.Yellow; Canvas.SetLeft(btnBack, 358); Canvas.SetTop(btnBack, 400); btnBack.BorderThickness = new Thickness(1); btnBack.BorderBrush = Brushes.Black; txtName.FontSize = 30; txtName.Background = Brushes.White; Canvas.SetLeft(txtName, 285); Canvas.SetTop(txtName, 125); txtName.MaxLength = 6; btnSubmitName.Click += btnSubmitName_Click; btnSubmitName.Content = "Submit"; btnSubmitName.FontSize = 40; btnSubmitName.Background = Brushes.Yellow; Canvas.SetLeft(btnSubmitName, 358); Canvas.SetTop(btnSubmitName, 400); btnSubmitName.BorderThickness = new Thickness(1); btnSubmitName.BorderBrush = Brushes.Black; System.IO.StreamReader sr = new System.IO.StreamReader("HighScores.txt"); for (int i = 0; i < 5; i++) { highScores[i] = sr.ReadLine(); } sr.Close(); player = new Player(0, 300, 6, 0, playerCanvas); zappers = new Zapper(canvas, random); zappers.generate(); for (int i = 0; i < 4; i++) { coins[i] = new Coin(i, canvas, random); coins[i].generate(); } SoundPlayer sp = new SoundPlayer("Rocket Man Soundtrack.wav"); sp.PlayLooping(); gameTimer.Tick += GameTimer_Tick; gameTimer.Interval = new TimeSpan(0, 0, 0, 0, 20); }