}//end MainWindow

        /// <summary>
        /// Runs for every frame (i.e. fps), controls everything.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameTimer_Tick(object sender, EventArgs e)
        {
            if (gameState == GameState.movingToGame)
            {
                pyramid = new Pyramid(canvas);
                pyramid.draw();
                gameState = GameState.GameOn;
                player    = new Player(pyramid, canvas);
            }//done movingtogame
            else if (gameState == GameState.GameOn)
            {
                player.update();//add logic for death
            }//done GameOn
        }//end GameTimer_Tick
Beispiel #2
0
        /// <summary>
        /// default constructor
        /// </summary>
        public Player(Pyramid p, Canvas c)
        {
            health   = 100;
            state    = PlayerState.alive;
            player   = new Rectangle();
            pyramid  = p;
            canvas   = c;
            position = pyramid.initializePlayer();


            _horizontalOffset = 50;
            _verticalOffset   = 50;
            player            = new Rectangle();
            player.Fill       = Brushes.Yellow;
            player.Width      = 50;
            player.Height     = 50;
            canvas.Children.Add(player);
            //position = new Point(position.X + 3, position.Y + 3);
            Canvas.SetLeft(player, 50 * position.Y + 25 + _horizontalOffset);
            Canvas.SetTop(player, 50 * position.X + 50 + _verticalOffset);
        }//end Player
 public MainWindow()
 {
     InitializeComponent();
     pyramid = new Pyramid(canvas);
     pyramid.draw();
 }