Ejemplo n.º 1
0
        private void KeyIsUp(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Left)
            {
                goLeft = false;
            }
            if (e.Key == Key.Right)
            {
                goRight = false;
            }

            if (e.Key == Key.Space)
            {
                Rectangle newBullet = new Rectangle
                {
                    Tag    = "bullet",
                    Height = 20,
                    Width  = 5,
                    Fill   = Brushes.White,
                    Stroke = Brushes.Red,
                };

                Canvas.SetTop(newBullet, Canvas.GetTop(player) - newBullet.Height);
                Canvas.SetLeft(newBullet, Canvas.GetLeft(player) + player.Width / 2);

                myCanvas.Children.Add(newBullet);
            }

            if (e.Key == Key.Enter && gameOver == true)
            {
                SpaceInvaders newSpace = new SpaceInvaders();
                Application.Current.MainWindow = newSpace;
                newSpace.Show();
                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void StartSpaceInvaders(object sender, RoutedEventArgs e)
        {
            SpaceInvaders spaceInvaders = new SpaceInvaders();

            spaceInvaders.Show();
        }