Example #1
0
        public GameLoop(LoopStrategy strategy)
        {
            if (strategy == null)
                throw new ArgumentNullException("strategy");

            m_strategy = strategy;
            m_loopState = new LoopState();
        }
Example #2
0
        public override void Loop(Game game, LoopState state)
        {
            state.Tick();
            accumulatedTime += state.NanoSeconds;
            updateCount = 0;

            while (accumulatedTime >= frameRate && updateCount < maxCount)
            {
                game.Update(state);
                updateCount++;
                accumulatedTime -= frameRate;
            }

            state.Interpolation = accumulatedTime/frameRate;

            game.Render(state);

            //var sleepTime = (frameRate - state.MilliSeconds);

            //if(sleepTime > 0)
            //    Thread.Sleep((int)sleepTime);
        }
Example #3
0
 public override void Loop(Game game, LoopState state)
 {
     state.Tick();
     game.Update(state);
     game.Render(state);
 }
Example #4
0
        public void Update(LoopState state)
        {
            lastX = x;
            lastY = y;
            x += xVelocity*/*(1.0/60.0);//*/ state.Seconds;
            y += yVelocity*/*(1.0/60.0);//*/ state.Seconds;

            //Debug.WriteLine("x,y - {0},{1}", x , y);

            HandelCollition();
        }
Example #5
0
 public void Render(LoopState state, AsciiGraphics g)
 {
     ax = /*x;//*/ (x - lastX) * state.Interpolation + lastX;
     ay = /*y;//*/ (y - lastY) * state.Interpolation + lastY;
     Debug.WriteLine("ay,ay - {0},{1}", ax, ay);
     g.DrawPoint(new AsciiPen('O', AsciiColors.Red), new Point((uint)ax, (uint)ay));
 }
Example #6
0
        public void Update(LoopState state)
        {
            state.Updates();
            bufferRender.Clear();

            dot.Update(state);
        }
Example #7
0
        public void Render(LoopState state)
        {
            state.Renderings();

            dot.Render(state, bufferRender);
            dispRender.DrawImage(buffer);
        }
Example #8
0
 public void ReadInput(LoopState state)
 {
 }