示例#1
0
        private void tmrPaint_Tick(object sender, EventArgs e)
        {
            // limpia opengl
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            //dibuja la escena
            controladora.DrawScene();
            //cambia los buffer
            Winapi.SwapBuffers(hdc);
            //termina de pintar
            Gl.glFlush();

            if (started)
            {
                score += 1;
                count1++;
                count2++;
                levelCount++;
                if (levelCount == 450)
                {
                    level++;
                    AsteroidGenerator.GenerateAsteroid(35, false);
                    lblLevel.Text = level.ToString();
                    levelCount    = 0;
                }
                if (count1 == 4)
                {
                    lblScore.Text = score.ToString();
                    count1        = 0;
                    lives         = controladora.Nave.Vidas;
                }
                if (count2 == 20)
                {
                    ShowLife(lives);
                    count2 = 0;
                    if (lives == 0)
                    {
                        started = false;
                        MessageBox.Show("Game Over");
                        controladora.ResetGame();
                        score         = 0;
                        level         = 1;
                        lives         = 3;
                        started       = true;
                        count1        = 0;
                        count2        = 0;
                        lblLevel.Text = level.ToString();
                    }
                }
            }
        }
示例#2
0
        private void tmrPaint_Tick(object sender, EventArgs e)
        {
            // opengl clean
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            //Draw the scene
            con.DrawScene();
            //Change the buffer
            Winapi.SwapBuffers(hdc);
            //Finish painting
            Gl.glFlush();

            if (started)
            {
                score += 1;
                count1++;
                count2++;
                levelCount++;
                if (levelCount == 450)
                {
                    level++;
                    AsteroidGenerator.GenerateAsteroid(35, false);
                    lblLevel.Text = level.ToString();
                    levelCount    = 0;
                }
                if (count1 == 4)
                {
                    lblScore.Text = score.ToString();
                    count1        = 0;
                    lives         = con.Nave.Lives;
                }
                if (count2 == 20)
                {
                    ShowLife(lives);
                    count2 = 0;
                    if (lives == 0)
                    {
                        started = false;
                        MessageBox.Show("Game Over");
                        con.ResetGame();
                        score         = 0;
                        level         = 1;
                        lives         = 3;
                        started       = true;
                        count1        = 0;
                        count2        = 0;
                        lblLevel.Text = level.ToString();
                    }
                }
            }
        }