Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Performance
#1
Quick question.

I understand the purpose of the "fwait" command and it use to control the "speed" (for want of a better word) of the program. What I would like to know is... is there a way for N7 to display the current FPS? For example: If I wanted to check the performance impact by moving more and more sprites on the screen... Or even like an FPS counter when running stress tests... that kind of thing...  I hope that I am making sense... Just curious...

J
Logic is the beginning of wisdom.
Reply
#2
(Yesterday, 02:29 AM)johnno56 Wrote: Quick question.

I understand the purpose of the "fwait" command and it use to control the "speed" (for want of a better word) of the program. What I would like to know is... is there a way for N7 to display the current FPS? For example: If I wanted to check the performance impact by moving more and more sprites on the screen... Or even like an FPS counter when running stress tests... that kind of thing...  I hope that I am making sense... Just curious...

J

Perhaps like this one .....

Code:
set window "FPS Checker",400,300

set redraw off

' Variables to calculate FPS
time_start = time()
frame_count = 0
fps = 0
fw = 60

'Main Loop
while not keydown(KEY_ESCAPE,true)
    ' Clear screen
    set color 32,32,32
    cls

    ' Frame counting
    frame_count = frame_count +1
    time_now = time()

    ' Calculate FPS every second
    if time_now - time_start >= 1 then
        fps = (frame_count) / (time_now - time_start)
        time_start = time_now
        frame_count = 0
    endif

    ' Display FPS
    set caret width()/2, height()/2
    set color 255,255,255
    center "Current FPS: " + fps

    ' Update screen
    redraw
   
    if keydown(KEY_UP,true) then fw = fw + 10
    if keydown(KEY_DOWN,true) then fw = fw - 10
   
    fwait fw

wend
Reply
#3
Excellent! Thank you!
Logic is the beginning of wisdom.
Reply
#4
(Yesterday, 04:59 AM)johnno56 Wrote: Excellent! Thank you!

Great example. 

I would just add the following to it, to make it easier to switch between max fps and 60 fps - I find that this really helps when you are trying to check fps, but still easily see how the game is running when the fps is set to a "normal" rate. You can retain the smaller increments/decrements in fw by amalgamating the key up and key down actions within this code, if desired.

Code:
if keydown(KEY_SPACE)
        fw = 1000
else
        fw = 60
endif 
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)