示例#1
0
文件: GameLoop.cs 项目: kridy/Snaky
        public GameLoop(LoopStrategy strategy)
        {
            if (strategy == null)
                throw new ArgumentNullException("strategy");

            m_strategy = strategy;
            m_loopState = new LoopState();
        }
示例#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);
        }
示例#3
0
文件: BasicLoop.cs 项目: kridy/Snaky
 public override void Loop(Game game, LoopState state)
 {
     state.Tick();
     game.Update(state);
     game.Render(state);
 }
示例#4
0
文件: Program.cs 项目: kridy/Snaky
        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();
        }
示例#5
0
文件: Program.cs 项目: kridy/Snaky
 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));
 }
示例#6
0
文件: Program.cs 项目: kridy/Snaky
        public void Update(LoopState state)
        {
            state.Updates();
            bufferRender.Clear();

            dot.Update(state);
        }
示例#7
0
文件: Program.cs 项目: kridy/Snaky
        public void Render(LoopState state)
        {
            state.Renderings();

            dot.Render(state, bufferRender);
            dispRender.DrawImage(buffer);
        }
示例#8
0
文件: Program.cs 项目: kridy/Snaky
 public void ReadInput(LoopState state)
 {
 }