Note that there are some explanatory texts on larger screens.

plurals
  1. POASCII DOS Games - Rendering methods
    primarykey
    data
    text
    <p>I'm writing an old school ASCII DOS-Prompt game. Honestly I'm trying to emulate ZZT to learn more about this brand of game design (Even if it is antiquated)</p> <p>I'm doing well, got my full-screen text mode to work and I can create worlds and move around without problems BUT I cannot find a decent timing method for my renders.</p> <p>I know my rendering and pre-rendering code is fast because if I don't add any delay()s or (clock()-renderBegin)/CLK_TCK checks from time.h the renders are blazingly fast.</p> <p>I don't want to use delay() because it is to my knowledge platform specific and on top of that I can't run any code while it delays (Like user input and processing). So I decided to do something like this:</p> <pre><code>do { if(kbhit()) { input = getch(); processInput(input); } if(clock()/CLOCKS_PER_SEC-renderTimer/CLOCKS_PER_SEC &gt; RenderInterval) { renderTimer = clock(); render(); ballLogic(); } }while(input != 'p'); </code></pre> <p>Which should in "theory" work just fine. The problem is that when I run this code (setting the RenderInterval to 0.0333 or 30fps) I don't get ANYWHERE close to 30fps, I get more like 18 at max.</p> <p>I thought maybe I'd try setting the RenderInterval to 0.0 to see if the performance kicked up... it did not. I was (with a RenderInterval of 0.0) getting at max ~18-20fps.</p> <p>I though maybe since I'm continuously calling all these clock() and "divide this by that" methods I was slowing the CPU down something scary, but when I took the render and ballLogic calls out of the if statement's brackets and set RenderInterval to 0.0 I get, again, blazingly fast renders.</p> <p>This doesn't make sence to me since if I left the if check in, shouldn't it run just as slow? I mean it still has to do all the calculations</p> <p>BTW I'm compiling with Borland's Turbo C++ V1.01</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload