Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1/5] [ALL VERSIONS OF MIRAGE] Better FPS Lock


ark0n
 Share

Recommended Posts

Step 1
Look for the current FPS Lock.
Step 2
  Remove the whole FPS Lock
Step 3
Add a timer to FrmMirage or FrmStable or whatever the place you have the PicScreen on.
and set its tickrate to 33ms. This will give it a 30 FPS Lock.
Step 4
Add the boolean canDraw as a Global Boolean
Step 5
In the tick section for that timer, have the code "canDraw = true"
Than after that, go to sub GameLoop

Step 6
As the first line add this code:
```
If Candraw = False Then
Exit Sub
else
Candraw = false
end if

```

That should be a much better FPS Lock :D
Credits:
Me: For making this tutorial
Homicidal Monkey: For teaching me how to do this.
Link to comment
Share on other sites

The point is so that you're not running through the entire loop only to start sleeping it to keep the FPS low.

This tutorial is horrible though. It has absolutely no explanation and it's pretty much you just copying & pasting Fabio's code over.
Link to comment
Share on other sites

@YamYam:

> Are they still doing that in Mirage nowadays then? I thought they stopped using that horrid method ages ago.

Mirage is dead. Active development and the community is, anyway.

The main sources now are my old Mirage Realms game which was released as open-source and Eclipse Origins.
Link to comment
Share on other sites

@Robin:

> This tutorial is horrible though. It has absolutely no explanation and it's pretty much you just copying & pasting Fabio's code over.

You claim that the tutorial is horrible, but is his edit horrible? Should I consider implementing this edit into my game?
Link to comment
Share on other sites

fixed it a little, you forgot to re-engage the lock.
Basically, it indirectly locks the fps by having a lock system based off of a timer, and pretty much guarantees that it will function at the desired framerate. You might want to set the timer to 33 instead of 66\. 1000ms (1 sec) / 30hz = 33ms.
Link to comment
Share on other sites

I think I'll put this in my code, thanks! However, I'm still confused as to how it works. You said to make a timer and set its Interval to 66, meaning it will execute every 66 milliseconds. When it executes, according to your tutorial, it will set **CanDraw** to **True**. Then, in the main **GameLoop**, you have this code:

```
If CanDraw = False Then
    Exit Sub
Else
    CanDraw = False
End if

```
So basically, every 66 milliseconds, **Sub GameLoop** stops executing for another 66 milliseconds to stop processes from executing? Something similar to this is seen in the existing Eclipse Evolution system, where the program stops execution using the **Sleep** command for 1 millisecond. The loop continues until 31 milliseconds have passed by, effectively keeping the FPS down to about 31.

With this system, as Robin pointed out, instead of going through the entire **GameLoop Sub** simply to lock the FPS, it does it at the beginning of the Sub so that it has to search through less code.

Even with the inaccuracy of the Timer API Tool Function, this still works well? Anyway, please let me know if I'm correct on all of this. Thanks!
Link to comment
Share on other sites

@Zetta:

> yeah, basically. Its also a more passive means of locking than the old fps lock. And you dont really need the timer to be accurate. If you get +- 5 ms accuracy, it really wont matter.

Okay, I got it. Thanks a lot!
Link to comment
Share on other sites

> Cool, lol. This work for EO?

I tried it following your very vague directions(Had to guess what you meant at times?) And it just froze the entire screen rendering it only once. And yes the timer was there. So I removed it and went on with doing other stuff. ;D
Link to comment
Share on other sites

  • 4 weeks later...
Jusus crist! I mean, holy hell. I am currently in shock at how fluently my game is running by changing that fps lock. It's amazing, really. I'm using my own engine which is based of the early mirage stuff and in all this time of developing I've never noticed this small error, do I feel stupid xD
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...