Results 1 to 10 of 14

Thread: game data and rendering mechanism

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ok making progres... running in GDI mode I have a form with Application.OnIdle set to the below method:
    Code:
    procedure TGameWindow.Idle(Sender: TObject; var Done: Boolean);
    begin
      CurrentTime := QueryTimer;
      if fGame.CheckTick(CurrentTime, LastTime) then // check elapsed time (>= 60 ms)
      begin
        fGamePainter.HandleInput(fInput); // if vk_left in keyboard then scroll left
        fGame.Tick;
        fGamePainter.Update;
        LastTime := CurrentTime;
      end;
      Done := False;
    end;
    Now the HandleInput (which stores keyboard state etc) is done in sync with the game ticks.
    Now if I - for example - want to speed up scrolling, is the best way to do this to have the GamePainter have its own timing and put the HandleInput at the first line of the method?
    Or else: what is a good central place to handle this? Tips are welcome

    BTW: Fullscreen GDI StretchDIBits gives me about 3000 FPS. Is this method hardware accelerated??

  2. #2
    Quote Originally Posted by ericlangedijk View Post
    BTW: Fullscreen GDI StretchDIBits gives me about 3000 FPS. Is this method hardware accelerated??
    Depends what happens in fGamePainter.Update; If you are not using OpenGL or DirectX, then it is not accelerated.

    While your loop timing works, it might have problems with no sleep() used, so the loop will use full potential of all allocated CPU cores. This can cause alot of heating and fan noise on powerful computers, or those with just a little faulty coolers. It can cause noise even from the monitor itself.

    You do not need 2 tick timers. Scrolling faster simply means changing scroll value more per frame. With timing system you have, you can move things at constant speed. But if you would have possibility to change framerate, or not limit it, you can count
    Code:
    frameMove:=(CurrentTime-LastTime)/1000;
    Using it as multiplicator for each movement, you can make things move as "per second".
    Code:
    player.X:=player.X+5*frameMove; // 5 units per second
    (However this doesn't actually result in as smooth animation in my experience, when compared to constant speed and set framerate.)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •