Exemplo n.º 1
0
        void Application_Idle(object sender, EventArgs e)
        {
            while (glControl1.IsIdle)// Main loop
            {
                howLong.Stop();
                double milliseconds = howLong.Elapsed.TotalMilliseconds;
                howLong.Reset();
                howLong.Start();

                oneSecCounter    += milliseconds;
                counter16ms      += milliseconds;
                totalTimeElapsed += milliseconds;

                if (oneSecCounter > 1000)//Check every second how many times Glcontrol was refreshed
                {
                    label1.Text   = "FPS:" + FPSCounter.ToString();
                    second        = (int)Math.Round(totalTimeElapsed) / 1000;
                    label1.Text  += " Totaltime:" + second.ToString();
                    FPSCounter    = 0;
                    oneSecCounter = 0;
                }
                if (counter16ms > 16) //refresh rate 60hz
                {
                    glManager.Render(glUserInput.UpdateLookAt());
                    fallingBody.Tick(glManager.exampleObjectManager.box, glManager.exampleObjectManager.box2);

                    counter16ms = 0;
                    FPSCounter++;
                }
            }
        }
Exemplo n.º 2
0
        public static void KeyDown(GLUserInput glUserInput, Keys key)
        {
            if (key == Keys.A)
            {
                glUserInput.TurnLeft();
            }
            if (key == Keys.D)
            {
                glUserInput.TurnRight();
            }
            if (key == Keys.W)
            {
                glUserInput.MoveForward();
            }
            if (key == Keys.S)
            {
                glUserInput.MoveBackward();
            }

            if (key == Keys.E)
            {
                glUserInput.MoveUp();
            }

            if (key == Keys.C)
            {
                glUserInput.MoveDown();
            }

            if (key == Keys.Q)
            {
                glUserInput.LookUp();
            }
            if (key == Keys.Z)
            {
                glUserInput.LookDown();
            }
            glUserInput.UpdateLookAt();
        }