Ejemplo n.º 1
0
        // This is normally called when it is time to set up the next frame.  The game
        // logic, therefore, would normally be placed here.  Originally, I thought that
        // this would be a good place to calculate the dt and update the positions,
        // velocities, and accelerations of the critters, etc.  However, after some
        // reflection, I realized that the OnRenderFrame (below) should be called as
        // often as possible, and the dt and updates should be done there.  I use the
        // OnUpdateFrame to just get input from the user, and have it set to get it
        // about 30 times per second.  This gives me really decent keyboard and mouse
        // sensitivity.  Meanwhile, all the time that it takes to calculate the updates,
        // etc., is included in the dt, since I do this in the OnRenderFrame.  -- JC
        public override void OnUpdateFrame(UpdateFrameEventArgs e)
        {
            for (int i = 0; i < vk.key.Length; i++)
            {
                if (Keyboard[vk.key[i]])
                {
                    keydev.setkey(i);
                }
                else
                {
                    keydev.resetkey(i);
                }
            }

            if (Mouse[MouseButton.Left])
            {
                leftclick = true;
            }
            else
            {
                leftclick = false;
            }

            if (Mouse.XDelta != 0 || Mouse.YDelta != 0)
            {
                view.OnMouseMove(new Point(Mouse.X, Mouse.Y));
            }
        }