コード例 #1
0
        private void tmrUpdate_Tick(object sender, EventArgs e)
        {
            //EVENTO TICK DEL TIMER "tmrUpdate": se comprueban los coliciones con muros bloques , vidas acitvas y las finalizacion del juego
            try
            {
                if (Settings.Playing && Settings.Hearts > 0)
                {
                    if (player.ballY + Settings.HeightBall1 >= Settings.MapHeight)
                    {
                        Settings.Hearts--;
                        StartBall = false;
                        Continue();
                    }

                    ChoqueMuros();
                    ChoquePlayer();
                    ColicionesBallBlocks();
                    lbScore.Text = "Score:" + Settings.Score;
                    if (Settings.Score >= Settings.ChangeScore1)
                    {
                        map.AddLine();
                        Settings.SpeedBall++;
                        Settings.ChangeScore1 += Settings.ChangeScore2;
                    }

                    if (StartBall)
                    {
                        player.ballX += player.dirX * Settings.SpeedBall;
                        player.ballY += player.dirY * Settings.SpeedBall;
                        if (player.AnnimationFrame < 3)
                        {
                            player.AnnimationFrame++;
                        }
                        else
                        {
                            player.AnnimationFrame = 0;
                        }
                    }
                    else
                    {
                        player.ballY = player.platformY - Settings.HeightBall1;
                        player.ballX = player.platformX + Settings.WidthPlayer1 / 2 - Settings.WidthBall1 / 2;
                    }

                    Invalidate();
                }
                else
                {
                    throw new NoLifesException("");
                }
            }catch (NoLifesException ex)
            {
                Settings.Playing = false;
                tmrJuego.Stop();
                tmrUpdate.Stop();
                var gameOver = new GameOver(nickname_current);
                gameOver.Show();
                this.Hide();
            }
        }