Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Frames per second VS milliseconds ?  (Read 5355 times)

0 Members and 1 Guest are viewing this topic.

Atelier Sentô

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
    • View Profile
    • Atelier Sentô
Frames per second VS milliseconds ?
« on: April 25, 2014, 04:14:47 PM »

Because I know nothing about programming, I've made some mistakes in my scripts.
Thanks to HCDaniel's help on this topic, I'm starting to understand that I should pay more attention to FPS.

I used to script scrolling scenes this way:
Code: WME Script
  1. // set the horizontal scrolling speed
Most of the time the scrolling speed was OK but sometime it was incredibly faster!

HCDaniel explained:
Quote
What makes me sceptical are the settings you use. You want the engine to scroll one pixel at a time, every 1ms. That would in theory result in 1000 pixels/second. Maybe with regular WME you use full screen, and it could be that the frames per second are limited (maybe to 100 or 60 I'm not sure), so there you'll get only 60 pixels per second at max.

I was thinking that, every 1ms, the scene would move by 1px.
But if I understand well, it all depends on FPS.
So if the game is played in 60FPS, my scene will scroll by 1px every 16ms. Am I right?

I've changed the script and wrote:
Code: WME Script
  1. // set the horizontal scrolling speed
And I have no problem with scrolling speed anymore.

After this revelation, I started to search for more infos on the WME Forums.

On this topic, I've read this comment from metamorphium:
Quote
it's quite usually bound to bad scripting. Constructions like Sleep(1); and the likes. You should always count with some FPS to boot and adjust wait cycles accordingly. Then you don't have this problem.

And on this topic, this other comment from metamorphium:
Quote
It's quite easy to set the Delays or Sleeps to desired framerate. If you are targeting for example your desired animation for 30fps, you know that every frame would take 1/30s so Delay or Sleep would be 33.

WME (unlike some other engines) doesn't limit you to certain fps, it rather lets you choose what suits you the best.

So if the game is played is 60FPS, when I write:
Code: WME Script
  1. Sleep (10);
Or
Code: WME Script
it won't be OK because the screen is only refreshed every 16ms.

So I should write instead

Code: WME Script
  1. Sleep (16);
Or
Code: WME Script

Am I right?
Or do I misunderstand something?

So here are my questions:

1- Should I design my game with a frame rate in mind?
Per exemple by using only multiples of 16 (16ms, 32ms, 48ms, 64ms,...)

If yes, what is the best value to use for having an homogeneous results on most of the computers?


2- When I write a Sleep(); command in ms, will this exact duration be used in all computers?
Or may it vary because of the computer frame rate, or any other factor?

Per example, let's imagine I want an animation to start during a dialogue when a character say one specific word.
I listen the dialogue and measure the length: the word is said 1400ms after the beginning.
So I write this script:
Code: WME Script
  1. actor.TalkAsync ("subtitle text", "filename.ogg", 3000);
  2. Sleep (1400);
  3. // the following node contains the animation sprite
  4. var animation = Scene.GetNode("animation");
  5. animation.Active = true;
  6. // then the game wait for the dialogue to end
  7. Sleep (1600);
Is there a risk for the animation to start too late or too early?
Is there a risk for the 2nd Sleep command to end before the end of the dialogue or too long after?
Should I trust the milliseconds?

I am sorry for asking so many questions those days.
Wintermute is very simple to understand and to use. And it's a real pleasure for a beginner like me to create a game with this tool.
Most of my problems come from the fact I know little about computers and how they work.

Thank you for reading me!
Logged

anarchist

  • Regular poster
  • ***
  • Karma: 5
  • Offline Offline
  • Gender: Male
  • Posts: 212
    • View Profile
Re: Frames per second VS milliseconds ?
« Reply #1 on: April 28, 2014, 07:07:06 PM »

I don't think I will be able to answer all your questions, but I am certain about one thing: any Sleep command issued by any application in x milliseconds means that the application will sleep for at least x milliseconds.

Therefore no, Sleep command does not guarantee, under any system, that the sleep time you choose will be the exact time the application actually sleeps. It will be ignored by the CPU for the duration you choose. When the sleep duration is over, it is queued along other concurrent processes and it will be processed whenever the CPU chooses to.
Logged

Atelier Sentô

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
    • View Profile
    • Atelier Sentô
Re: Frames per second VS milliseconds ?
« Reply #2 on: April 28, 2014, 07:34:34 PM »

It explains a lot of things.
That's for sure something I will keep in mind while making my game.

So, if durations are relative, what's important is to write scripts where the durations can be longer than expected without being noticed by the player.

Thank you for your answer!
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Frames per second VS milliseconds ?
« Reply #3 on: May 14, 2014, 12:55:43 PM »

My suggestion is - always time it relatively to other events. Absolute time on ms scale just performs totally different on different machines.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Atelier Sentô

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 52
    • View Profile
    • Atelier Sentô
Re: Frames per second VS milliseconds ?
« Reply #4 on: May 14, 2014, 07:11:53 PM »

Thank you: it sounds wise. I'll work in that way.
Logged
 

Page created in 0.023 seconds with 21 queries.