This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Game Development and the fly likes period rate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "period rate" Watch "period rate" New topic
Author

period rate

Fernando hiar
Greenhorn

Joined: Jan 11, 2008
Posts: 29
I have a doubt about the period rate, I buy a book Killer programming game in java and I don´t understanding about the period what value i have in period in this formula - Sleeptime = period - timediff - oversleeptime, I know the value of sleeptime, i know the value about the timediff and i know the value of oversleeptime, but i don´t have the value of period, how can i found this value - i know the period is the same fps in ms.


thanks,

Fernando.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

ummm....

S = P - T - O

you say you know the value of three of the four. Basic algebra lets you find the last. At 'T' and O to both sides:

S + T + O= P - T + T- O + O

S + T + O = P.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Fernando hiar
Greenhorn

Joined: Jan 11, 2008
Posts: 29
I know this formula, but this book put a condition if sleeptime > 0 so the timediff took a longer time , how can i say if the sleeptime is negative if i don´t know the period : sleeptime = period - timediff - oversleeptime. I don´t know the value of period, how can i know sleeptime become negative?



thamks,

Fernando.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

maybe i'm just not understanding what you're asking... but...

S = P - T - O

is the same as

S = P - (T+O)

From here, it should be easy to see that S will be negative if (T+O) is greater than P.

Now, if you only have one equation with four variables, you CAN'T solve it if you only know the value of 2 of them. You have to have at least one equation for each unknown variable.
Fernando hiar
Greenhorn

Joined: Jan 11, 2008
Posts: 29
So.....
Are you trying to ask me is when sleeptime > or < 0 the program knows the value of period period = sleeptime + timediff + oversleeptime or the program knows if timediff take a long time the sleeptime becomes negative even don´t know the value of period? It is i want to know I understood what you teaching me, but still stay this doubt.


thanks,

Fernando.
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Fernando, You'll get your answer a lot faster if you posted a small piece of code so we can see exactly where the problem is. I'm still having a hard time figuring out what variables you know the value of, which ones you don't, and what the problem is exactly. Please post some code and put a comment in as to where you should be getting a value that you can't seem to get.


SCJA
~Currently preparing for SCJP6
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11167
    
  16

going back to your original post, you said this:

Sleeptime = period - timediff - oversleeptime, I know the value of sleeptime, i know the value about the timediff and i know the value of oversleeptime, but i don´t have the value of period


I took this to mean you have this formula:

Sleeptime = period - timediff - oversleeptime

You then said you "know the value of sleeptime", and that you "know the value of oversleeptime".

I'm not sure what you mean by you "know the value about the timediff" - it's that word 'about' that is confusing. do you know the value of timediff or not?

If you DO know it, getting the value of period is trivial.

If you DO NOT know it, you CAN'T get the value of period without more information.
Fernando hiar
Greenhorn

Joined: Jan 11, 2008
Posts: 29
I want to know one thing, if i have the value of all variables less one the period sleeptime = period - timediff - oversleeptime, the jvm can get the period value and use this value and each cycle???



thanks,

Fernando.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: period rate
 
Similar Threads
Setting a value for Sleep from the command line
frame rate slowly increases
Moving graphic in relation to another
reading foreign characters (say, multi-byte charcters, Japanese, Turkish, etc) from a file in java.
Huge Salaries - Less take home