Exemplo n.º 1
0
        // Handles keyboard presses
        private void MainWindow_KeyHandler(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.W || e.Key == Key.Up)
            {
                player.addRow(-1);
            }

            else if (e.Key == Key.S || e.Key == Key.Down)
            {
                player.addRow(1);
            }

            else if (e.Key == Key.D || e.Key == Key.Right)
            {
                player.addCol(1);
            }

            else if (e.Key == Key.A || e.Key == Key.Left)
            {
                player.addCol(-1);
            }

            player.draw(MainGrid);

            checkEndCondition();
        }
Exemplo n.º 2
0
        private void StartGame()
        {
            removeOld();

            milis = DateTimeOffset.Now.ToUnixTimeMilliseconds();
            id++;
            bombs  = new GridElement[15];
            player = new GridElement(0, 0, r.Next(0, 10), 1);

            // Setting location of the bombs
            for (var i = 0; i < bombs.Length; i++)
            {
                bombs[i] = new GridElement(i + 1, r.Next(1, 10), r.Next(0, 10), 0);
            }

            drawBombs();
            player.draw(MainGrid);  // Draws the player car
        }