Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: game data and rendering mechanism

  1. #11
    Quote Originally Posted by ericlangedijk View Post
    How does TRenderer 'know' that Character[N] has a bitmap[N] for drawing?
    The question is made slightly wrong. Character doesn't have any bitmaps, only different properties and states (such as "humanoid type 4 with blue helmet and white armor is jumping at animation phase 0.6, at coords X, Y"). How you define those is only limited by your imagination Only renderer class/unit needs to store the possible bitmap/texture/model data. Make good use of indexes sometimes. For example:
    Code:
    Renderer unit has:
    model: array of T3DModel;
    
    Game unit has:
    TPlayer = class
      modelIndex: integer; // This would refer to model in renderer class
      animFrame, animDelta: single;
    end;

  2. #12
    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??

  3. #13
    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.)

  4. #14
    Ok thanks. I think that for smooth scrolling I need an extra time-measurement.

    Update = StretchDIBits.

    Strange thing is that on another computer - same Windows 7 PC and just a tiny fraction slower than my own - the framerate is about 64. Which is at least a factor 400 slower! What can be the causes of this?

Page 2 of 2 FirstFirst 12

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
  •