2 registered members (TipmyPip, 1 invisible),
18,731
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: when will the engine render?
[Re: edisontsui]
#54394
09/07/05 04:50
09/07/05 04:50
|
Joined: Feb 2003
Posts: 6,818 Minot, North Dakota, USA
ulillillia
Senior Expert
|
Senior Expert
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
|
If you use the wait(1) instruction at the end of the while loop, then the count will happen once every frame. I have something similar myself in my 2D game based strictly on 60 fps, but it counts frames, seconds, and minutes. It behaves exactly as I expected it to (although it's slightly a little on the fast side as I can't lock the frame rate exactly on 60 for some reason).
"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip
My 2D game - release on Jun 13th; My tutorials
|
|
|
Re: when will the engine render?
[Re: edisontsui]
#54396
09/07/05 06:55
09/07/05 06:55
|
Joined: Feb 2003
Posts: 6,818 Minot, North Dakota, USA
ulillillia
Senior Expert
|
Senior Expert
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
|
What I'm saying is that the function is executed once every frame and within that frame. At the end of all the functions, the view is updated and the process begins again for the next frame. After all functions currently running are done, the view is updated again. They're run again and the view is updated. At this point, the variable would now have a value of 3 as three frames have passed. Copy this into your script and see for yourself:
var frame_count = 0;
function count_for_me() { frame_count += 1; }
Now add this at the very top of the main function:
fps_max = 10; // 10 frames per second maximum fps_lock = on; // locks it count_for_me(); // begins the count
Try playing around with the fps_max value. I prefer you do this in a very simple and empty-looking level or you might run into problems. If you want to toggle the frame rate, add this above the main function:
var max_frame_rate = 10;
function toggle_frame_rate() { if (max_frame_rate == 10) { max_frame_rate = 15; fps_max = 15; return(0); }
if (max_frame_rate == 15) { max_frame_rate = 20; fps_max = 20; return(0); }
if (max_frame_rate == 20) { max_frame_rate = 30; fps_max = 30; return(0); }
if (max_frame_rate == 30) { max_frame_rate = 60; fps_max = 60; return(0); }
if (max_frame_rate == 60) { max_frame_rate = 10; fps_max = 10; return(0); } } on_f = toggle_frame_rate();
And when you run your level, press the F key to switch between the different frame rates and see how it affects your value. Of course, to see it, you'll need a panel (add this anywhere above the main function):
panel show_frame_count { pos_x = 8; // top left corner pos_y = 8; layer = 15; digits = 0, 0, 7, _a4font, 1, frame_count; flags = visible; // make it visible }
From there, you should be set. If you have a moving object visible that moves constantly in your level, you can monitor the frame rate that way. The jerkier it is, the lower the frame rate and the slower the count should increase. The smoother it is, the higher the frame rate and the faster the count should increase.
Hopefully that'll get you somewhere. You might need to modify the code to fix any syntax errors I might've left out.
"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip
My 2D game - release on Jun 13th; My tutorials
|
|
|
Re: when will the engine render?
[Re: edisontsui]
#54398
09/07/05 07:10
09/07/05 07:10
|
Joined: Feb 2003
Posts: 6,818 Minot, North Dakota, USA
ulillillia
Senior Expert
|
Senior Expert
Joined: Feb 2003
Posts: 6,818
Minot, North Dakota, USA
|
No problem. I use this with my 2D game for the clock, challenge timers and other things and I've got a few functions running constantly (8 in normal mode, 3 in frame advance mode).
"You level up the fastest and easiest if you do things at your own level and no higher or lower" - useful tip
My 2D game - release on Jun 13th; My tutorials
|
|
|
|