コード例 #1
0
        Vector2 ChangeView(GameTime gameTime)
        {
            const float VERTICAL_INVERSION = -1.0f; // vertical view control
            // negate to reverse

            // handle change in view using right and left keys
            int widthMiddle = glControl.Width / 2;
            int heightMiddle = glControl.Height / 2;
            Vector2 change = Vector2.Zero;

            float scaleY = VERTICAL_INVERSION * (float)gameTime.ElapsedMilliseconds / 100.0f;
            float scaleX = (float)gameTime.ElapsedMilliseconds / 400.0f;

            // cursor not at center on X
            if (MouseState.X != widthMiddle)
            {
                change.X = MouseState.X - widthMiddle;
                change.X /= scaleX;
            }
            // cursor not at center on Y
            if (MouseState.Y != heightMiddle)
            {
                change.Y = MouseState.Y - heightMiddle;
                change.Y /= scaleY;
            }
            // reset cursor back to center
            MouseState.SetPosition(glControl.PointToScreen(new Point((int)widthMiddle, (int)heightMiddle)));
            return change;
        }
コード例 #2
0
        protected void Update(object sender, GameTime gameTime)
        {
            if (KeyboardState.IsKeyDown(Keys.Escape)) this.Close();

            // (float)gameTime.ElapsedMilliseconds()/6000
            modelviewMatrix *= Matrix4.CreateRotationY(0.005F) * Matrix4.CreateTranslation(locX, locY, locZ);

            float inc = 0.0012F;
            locX += inc * fX;
            locY += inc * fY * 1.8F;
            locZ += inc * fZ * 1.15F;
            if (locX >  .1F && fX == 1) fX = -1; else if (locX < -.1F && fX == -1) fX = 1;
            if (locY >  .1F && fY == 1) fY = -1; else if (locY < -.1F && fY == -1) fY = 1;
            if (locZ >  .1F && fZ == 1) fZ = -1; else if (locZ < -.1F && fZ == -1) fZ = 1;

            // update camera
            //cam.SetFrameInterval(gameTime);
            //cam.Move(Move());
            //cam.Strafe(Strafe());
            //cam.SetView(ChangeView(gameTime));

            //modelviewMatrix *= Matrix4.CreateTranslation(Move() * Vector3.UnitZ);
            //modelviewMatrix = cam.viewMatrix;
            effect.View = modelviewMatrix;
        }
コード例 #3
0
 static GameTime()
 {
     _staticReference = new GameTime();
     game = new Timer();
     game.Interval = 30;
     game.Tick += game_Tick;
 }
コード例 #4
0
        protected void Draw(object sender, GameTime gameTime)
        {
            Renderer.Clear();

            effect.Draw();

            glControl.SwapBuffers();
        }
コード例 #5
0
 private void gameTick(object sender, GameTime e)
 {
     glControl.Invalidate();
 }
コード例 #6
0
ファイル: Camera.cs プロジェクト: TekuConcept/Folding-Atomata
 /// <summary>
 /// Sets time lapse between frames
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 public void SetFrameInterval(GameTime gameTime)
 {
     timeLapse = (float)gameTime.ElapsedMilliseconds;
 }