Пример #1
0
        private static void MixInput(INP inpId, int keyId, int btnId)
        {
            int freezeInputFrame_BKUP = GameEngine.FreezeInputFrame;

            GameEngine.FreezeInputFrame = 0;

            bool keyDown = 1 <= GameKeyboard.GetKeyInput(keyId);
            bool btnDown = 1 <= GamePad.GetPadInput(GameGround.I.PrimaryPadId, btnId);

            GameEngine.FreezeInputFrame = freezeInputFrame_BKUP;

            GameDefine.UpdateInput(ref InputStatus[(int)inpId], keyDown || btnDown);
        }
Пример #2
0
        // -- 他のファイルからは read only ここまで

        private static void CheckHz()
        {
            long currTime = GameSystem.GetCurrTime();

            if (ProcFrame == 0)
            {
                HzChaserTime = currTime;
                LowHzTime    = currTime;
            }
            else
            {
                HzChaserTime += 16;                 // 16.666 より小さいので、60Hzならどんどん引き離されるはず。
                LowHzTime    += 17;
            }

            while (currTime < HzChaserTime)
            {
                Thread.Sleep(1);

                // DxLib >

                DX.ScreenFlip();

                if (DX.ProcessMessage() == -1)
                {
                    throw new GameError.EndProc();
                }

                // < DxLib

                currTime = GameSystem.GetCurrTime();
                GameDefine.Approach(ref EatenByLangolierEval, 1.0, 0.9);
            }
            EatenByLangolierEval *= 0.99;

            if (LowHzTime < currTime)
            {
                LowHzTime = Math.Max(LowHzTime, currTime - 10);
                GameDefine.Approach(ref LowHzErrorRate, 1.0, 0.999);
            }
            else
            {
                LowHzTime       = Math.Min(LowHzTime, currTime + 20);
                LowHzErrorRate *= 0.99;
            }

            Console.WriteLine(currTime + ", " + (currTime - FrameStartTime));             // test

            FrameStartTime = currTime;
        }
Пример #3
0
        public void MouseEachFrame()
        {
            uint status;

            if (GameEngine.WindowIsActive)
            {
                MouseRot = DX.GetMouseHWheelRotVol();
                status   = (uint)DX.GetMouseInput();
            }
            else             // ? 非アクティブ -> 無入力
            {
                MouseRot = 0;
                status   = 0u;
            }
            MouseRot = IntTools.ToRange(MouseRot, -IntTools.IMAX, IntTools.IMAX);

            GameDefine.UpdateInput(ref MouseStatus[(int)MOUBTN.L], (status & DX.MOUSE_INPUT_LEFT) != 0u);
            GameDefine.UpdateInput(ref MouseStatus[(int)MOUBTN.M], (status & DX.MOUSE_INPUT_MIDDLE) != 0u);
            GameDefine.UpdateInput(ref MouseStatus[(int)MOUBTN.R], (status & DX.MOUSE_INPUT_RIGHT) != 0u);
        }
Пример #4
0
        public static void PadEachFrame()
        {
            int padCount = GetPadCount();

            for (int padId = 0; padId < padCount; padId++)
            {
                uint status;

                if (GameEngine.WindowIsActive)
                {
                    status = (uint)DX.GetJoypadInputState(PadId2InputType(padId));
                }
                else                 // ? 非アクティブ
                {
                    status = 0u;     // 無入力
                }
                if (status != 0u)
                {
                    for (int btnId = 0; btnId < PAD_BUTTON_MAX; btnId++)
                    {
                        GameDefine.UpdateInput(ref Pads[padId].ButtonStatus[btnId], (status & (1u << btnId)) != 0u);
                    }
                }
                else
                {
                    for (int btnId = 0; btnId < PAD_BUTTON_MAX; btnId++)
                    {
                        GameDefine.UpdateInput(ref Pads[padId].ButtonStatus[btnId], false);
                    }
                }

                if (GameGround.I.PrimaryPadId == -1 && 10 < GameEngine.ProcFrame && Pads[padId].Status == 0u && status != 0u)                 // 最初にボタンを押下したパッドを PrimaryPadId にセット
                {
                    GameGround.I.PrimaryPadId = padId;
                }

                Pads[padId].Status = status;
            }
        }
Пример #5
0
        public static void KeyEachFrame()
        {
            if (GameEngine.WindowIsActive)
            {
                if (DX.GetHitKeyStateAll(StatusMap) != 0)                 // ? 失敗
                {
                    throw new GameError();
                }

                for (int keyId = 0; keyId < KEY_MAX; keyId++)
                {
                    GameDefine.UpdateInput(ref KeyStatus[keyId], StatusMap[keyId] != 0);
                }
            }
            else             // ? 非アクティブ -> 無入力
            {
                for (int keyId = 0; keyId < KEY_MAX; keyId++)
                {
                    GameDefine.UpdateInput(ref KeyStatus[keyId], false);
                }
            }
        }
Пример #6
0
        public static void EachFrame()
        {
            //if (SEEachFrame()) // TODO
            {
                GameMusic.MusicEachFrame();
            }
            GameGround.I.EL.ExecuteAllTask();
            GameToolkit.CurtainEachFrame();

            if (GameGround.I.MainScreen != null && SubScreen.CurrDrawScreenHandle == GameGround.I.MainScreen.GetHandle())
            {
                SubScreen.ChangeDrawScreen(DX.DX_SCREEN_BACK);

                if (GameGround.I.RealScreenDrawRect.W == -1)
                {
                    if (DX.DrawExtendGraph(0, 0, GameGround.I.RealScreenSize.W, GameGround.I.RealScreenSize.H, GameGround.I.MainScreen.GetHandle(), 0) != 0)                     // ? 失敗
                    {
                        throw new GameError();
                    }
                }
                else
                {
                    if (DX.DrawBox(0, 0, GameGround.I.RealScreenSize.W, GameGround.I.RealScreenSize.H, DX.GetColor(0, 0, 0), 1) != 0)                     // ? 失敗
                    {
                        throw new GameError();
                    }

                    if (DX.DrawExtendGraph(
                            GameGround.I.RealScreenDrawRect.L,
                            GameGround.I.RealScreenDrawRect.T,
                            GameGround.I.RealScreenDrawRect.L + GameGround.I.RealScreenDrawRect.W,
                            GameGround.I.RealScreenDrawRect.T + GameGround.I.RealScreenDrawRect.H, GameGround.I.MainScreen.GetHandle(), 0) != 0)                     // ? 失敗
                    {
                        throw new GameError();
                    }
                }
            }

            // DxLib >

            DX.ScreenFlip();

            if ((IgnoreEscapeKey == false && DX.CheckHitKey(DX.KEY_INPUT_ESCAPE) == 1) || DX.ProcessMessage() == -1)
            {
                throw new GameError.EndProc();
            }

            // < DxLib

            CheckHz();

            ProcFrame++;
            if (IntTools.IMAX < ProcFrame)             // 192.9日程度でカンスト
            {
                throw new GameError();
            }
            GameDefine.CountDown(ref FreezeInputFrame);
            WindowIsActive = GameSystem.IsWindowActive();

            GamePad.PadEachFrame();
            GameKeyboard.KeyEachFrame();
            GameInput.InputEachFrame();
            GameMouse.I.MouseEachFrame();

            if (GameGround.I.RealScreenSize.W != GameGround.I.ScreenSize.W || GameGround.I.RealScreenSize.H != GameGround.I.ScreenSize.H)
            {
                if (GameGround.I.MainScreen == null)
                {
                    GameGround.I.MainScreen = new SubScreen(GameGround.I.ScreenSize.W, GameGround.I.ScreenSize.H);
                }

                SubScreen.ChangeDrawScreen(GameGround.I.MainScreen);
            }
        }