Frames Per Second Best Practice

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Frames Per Second Best Practice

Post by istech » Tue Aug 26, 2014 9:06 am

Hi All,

I work with a lot of animations with LC and would like to get a better grasp of FPS in livecode and if my approach is correct and any optimization tips or links.

At the moment what I do is if I make a animation built with 12FPS and want to add it to a project I use the "send" command and divide 1000 by 12 which is 83.3 and send it to me. (1000ms = 1 second)

Is this approach a good practice? and what other methods do others use. thanks.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Frames Per Second Best Practice

Post by jmburnod » Tue Aug 26, 2014 11:28 am

Hi Istech,
I understood the send command is better than repeat loop.
divide 1000 by 12 which is 83.3 and send it to me
I think you have to use round function to get an integer
The main problem for you is what doing during 4 milliseconds 1000-(83 * 12) = 4 :roll:
Best regards
Jean-Marc
https://alternatic.ch

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Frames Per Second Best Practice

Post by MaxV » Tue Aug 26, 2014 2:03 pm

In videogame programming, no matter programming language you use, the best effect are cheating user senses.
If you need speed, sometime the best effect is to skip some animations. The classic example is the rolling wheel that go faster and faster:
  • bad programmers write a cycle that rotate wheels of 1 degrees per cylce and speed up the cycle
  • good programmers use always the same time for the cycle, but the increase the angle rotation per cycle
However a way is to build an animated GIF and use it. GIF are transparent and you may change:
no animation

Code: Select all

 set the repeatCount of image "MyImage" to 0
infinite animation

Code: Select all

 set the repeatCount of image "MyImage" to -1
just 3 animation loops

Code: Select all

 set the repeatCount of image "MyImage" to 3
GIF speed is setted inside GIF, not by Livecode.

another way is to use tick instead of seconds:

Code: Select all

send animationAdvaceOneFrame to me in 2 tick 
but probably the last way is too fast, and it's difficult to control the pendingMessages list.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: Frames Per Second Best Practice

Post by istech » Tue Sep 02, 2014 1:26 pm

MaxV wrote:In videogame programming, no matter programming language you use, the best effect are cheating user senses.
If you need speed, sometime the best effect is to skip some animations. The classic example is the rolling wheel that go faster and faster:
  • bad programmers write a cycle that rotate wheels of 1 degrees per cylce and speed up the cycle
  • good programmers use always the same time for the cycle, but the increase the angle rotation per cycle
Thanks for the useful info.

Post Reply