[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  updating miniwindows more frequently than 1/10th a second

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

updating miniwindows more frequently than 1/10th a second

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Hollisgf   (4 posts)  [Biography] bio
Date Thu 25 Aug 2011 06:12 AM (UTC)  quote  ]
Message
I am writing a MUSHclient plugin for my mud. The mud makes makes frequent use of 3-second windows for actions. I would like to visually display these windows by having a bar that slowly drains from "full" to "empty" over the course of the window.

I have tried doing this with timers, but they are capped at 0.1 second resolution, which makes the draining look very choppy.

Is there an alternate way I could go about doing there, where I can update the bar at a higher frequency? Say, once ever 0.01 seconds?
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Reply #1 on Thu 25 Aug 2011 06:51 AM (UTC)  quote  ]
Message
You can implement an OnPluginTick callback, which is provided specifically for doing animations. It's called 25 times a second.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
[Go to top] top

Posted by Hollisgf   (4 posts)  [Biography] bio
Date Reply #2 on Thu 25 Aug 2011 07:50 AM (UTC)  quote  ]
Message
Aha! Better, but still a little jumpy. Is there anything else that is a little faster?
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Thu 25 Aug 2011 08:08 AM (UTC)  quote  ]
Message
25 frames per second is about what movies are recorded at.

Make sure you are updating the screen (maybe call Repaint, although that can be pretty CPU intensive). At least make sure you are calling Redraw.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hollisgf   (4 posts)  [Biography] bio
Date Reply #4 on Thu 25 Aug 2011 08:33 AM (UTC)  quote  ]
Message
Yup, I am repainting and it is still choppy (not as bad as using timers though).

Movies look smooth at 25 fps because they have lots of things changing; more changes in our field of view means a lower frequency threshold for perceiving apparent motion as smooth change. When there are fewer things changing, we have a much higher threshold for perceiving apparent motion as smooth change. It's basic human vision. Standard arguments about fps don't really apply to small changes.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 25 Aug 2011 09:55 AM (UTC)  quote  ]
Message
If you have a bar of more than 75 pixels width, and it has to drain in 3 seconds, some choppiness is going to be unavoidable at 25 fps. eg. if it is 150 pixels wide, it will decrease at the rate of 2 pixels each time.

You could make timers have a higher resolution, but as other threads have discovered, Windows timers are actually quite a low priority. So you can specify a 1/1000 of a second resolution, but that might not be realized if some other higher-priority event happens first (like, data from the MUD).

It's a trade-off. You could have really smooth animations, but slower responses to messages from the MUD.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Hollisgf   (4 posts)  [Biography] bio
Date Reply #6 on Thu 25 Aug 2011 10:34 AM (UTC)  quote  ]
Message
Ohh, duh... I shrunk the bars down from 180 pixels to 75, and it looks much nicer now. Thanks!
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,358 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]