예제 #1
0
        private void OnUpdate(object sender, GameTimerEventArgs e)
        {
            if (isClose)
            {
                return;
            }
            if (process != null)
            {
                process.Load();
                process.Calls();

                elapsedTime = e.ElapsedTime.Ticks / 10000L;

                process.InputUpdate(elapsedTime);

                ActionControl.Update(elapsedTime);

                timerContext.millisSleepTime     = sleepTime;
                timerContext.timeSinceLastUpdate = elapsedTime;

                process.RunTimer(timerContext);
                process.Unload();
            }
            if (useXNAListener)
            {
                sl_listener.Update(GamePage, e);
            }
        }
예제 #2
0
        protected override void Update(GameTime gameTime)
        {
            if (isClose)
            {
                return;
            }
            if (process != null)
            {
                process.Load();
                process.Calls();

                elapsedTime = gameTime.ElapsedGameTime.Ticks / 10000L;

                process.InputUpdate(elapsedTime);

                ActionControl.Update(elapsedTime);

                timerContext.millisSleepTime     = sleepTime;
                timerContext.timeSinceLastUpdate = elapsedTime;

                process.RunTimer(timerContext);
                process.Unload();
            }
            if (useXNAListener)
            {
                xna_listener.Update(this, gameTime);
            }
            if (UseXNA)
            {
                base.Update(gameTime);
            }
        }
예제 #3
0
        public override void Draw(GL g)
        {
            this.m_onRunning = false;
            this.m_onPause   = false;
            this.m_onDestroy = false;
            this.m_onResume  = false;

            lock (m_sync)
            {
                m_onRunning = LSystem.isRunning;
                m_onPause   = LSystem.isPaused;
                m_onDestroy = LSystem.isDestroy;
                m_onResume  = LSystem.isResume;

                if (LSystem.isResume)
                {
                    LSystem.isResume = false;
                }

                if (LSystem.isPaused)
                {
                    LSystem.isPaused = false;
                    JavaRuntime.NotifyAll(m_sync);
                }

                if (LSystem.isDestroy)
                {
                    LSystem.isDestroy = false;
                    JavaRuntime.NotifyAll(m_sync);
                }

                if (m_onResume)
                {
                    m_log.I("m_onResume");
                    timer           = LSystem.GetSystemTimer();
                    lastTimeMicros  = timer.GetTimeMicros();
                    elapsedTime     = 0;
                    remainderMicros = 0;
                    m_process.OnResume();
                }


                if (m_onRunning)
                {
                    if (LSystem.isLogo)
                    {
                        if (logoFlag == null)
                        {
                            LSystem.isLogo = false;
                            return;
                        }
                        logoFlag.Draw(m_process.gl);
                        if (logoFlag.finish)
                        {
                            m_process.gl.SetAlpha(1.0f);
                            m_process.gl.DrawClear(LColor.black);
                            LSystem.isLogo = false;
                            logoFlag.Dispose();
                            logoFlag = null;
                            return;
                        }
                        return;
                    }

                    if (!m_process.Next())
                    {
                        return;
                    }

                    m_process.Load();

                    m_process.Calls();

                    goalTimeMicros    = lastTimeMicros + 1000000L / maxFrames;
                    currTimeMicros    = timer.SleepTimeMicros(goalTimeMicros);
                    elapsedTimeMicros = currTimeMicros - lastTimeMicros
                                        + remainderMicros;
                    elapsedTime     = MathUtils.Max(0, (elapsedTimeMicros / 1000));
                    remainderMicros = elapsedTimeMicros - elapsedTime * 1000;
                    lastTimeMicros  = currTimeMicros;
                    timerContext.millisSleepTime     = remainderMicros;
                    timerContext.timeSinceLastUpdate = elapsedTime;

                    ActionControl.Update(elapsedTime);

                    m_process.RunTimer(timerContext);

                    if (LSystem.AUTO_REPAINT)
                    {
                        GLEx gl = m_process.gl;

                        if (gl != null)
                        {
                            if (!m_process.Next())
                            {
                                return;
                            }

                            //设定graphics.PreferredBackBufferWidth和graphics.PreferredBackBufferHeight时WP会自动缩放画面,
                            //此处无需再缩放一次。

                            /*if (LSystem.scaleWidth != 1f || LSystem.scaleHeight != 1f)
                             * {
                             *  gl.Scale(LSystem.scaleWidth,
                             *          LSystem.scaleHeight);
                             * }*/

                            int repaintMode = m_process.GetRepaintMode();

                            switch (repaintMode)
                            {
                            case Screen.SCREEN_BITMAP_REPAINT:
                                gl.Reset(true);
                                if (m_process.GetX() == 0 && m_process.GetY() == 0)
                                {
                                    gl.DrawTexture(m_process.GetBackground(), 0, 0);
                                }
                                else
                                {
                                    gl.DrawTexture(m_process.GetBackground(), m_process.GetX(),
                                                   m_process.GetY());
                                }
                                break;

                            case Screen.SCREEN_COLOR_REPAINT:
                                LColor c = m_process.GetColor();
                                if (c != null)
                                {
                                    gl.DrawClear(c);
                                }
                                break;

                            case Screen.SCREEN_CANVAS_REPAINT:
                                gl.Reset(true);
                                break;

                            case Screen.SCREEN_NOT_REPAINT:
                                gl.Reset(true);
                                break;

                            default:
                                gl.Reset(true);
                                if (m_process.GetX() == 0 && m_process.GetY() == 0)
                                {
                                    gl.DrawTexture(
                                        m_process.GetBackground(),
                                        repaintMode / 2
                                        - LSystem.random.Next(repaintMode),
                                        repaintMode / 2
                                        - LSystem.random.Next(repaintMode));
                                }
                                else
                                {
                                    gl.DrawTexture(m_process.GetBackground(),
                                                   m_process.GetX() + repaintMode / 2
                                                   - LSystem.random.Next(repaintMode),
                                                   m_process.GetY() + repaintMode / 2
                                                   - LSystem.random.Next(repaintMode));
                                }
                                break;
                            }

                            m_process.Draw();

                            m_process.Drawable(elapsedTime);

                            if (isFPS)
                            {
                                this.TickFrames();
                                fpsFont.DrawString(string.Format(numformat, "FPS:{0}", frameRate), 5, 5, 0, LColor.white);
                            }

                            m_process.DrawEmulator();

                            m_process.Unload();

                            gl.Restore();
                        }
                    }
                }
            }
        }