Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Timer alternatives in Applets?  (Read 2510 times)
0 Members and 1 Guest are viewing this topic.
Offline Murdockian

Senior Newbie

Java games rock!

« Posted 2003-10-13 12:59:58 »

Hi there!

Thanx for a great forum and (so far) great answers. I 'm developing Applet games and have (finally!) begun to see how things should be done!

I'm currently running in windowmode @ 150 fps which makes my games quite fast since they were designed in the "old fashioned way" where you move as many times / sec as you repaint (that is like 25 fps...) Therefore I need to seperate the rendering frmo the animation and I found Markus Persson's grate piece on discrete stepping but I can't make it work properly since I don't have a HQ timer in Applets....

So - The actual question would be:
How can I control the velocity in my applet games WITHOUT a discrete stepping algorithm whcih require a timer that I don't have access to;

How can I make use of the discrete stepping algorithm from my Applet without a HQ timer?

/Suggestions plz?
Offline tom
« Reply #1 - Posted 2003-10-13 17:07:11 »

In my applets I assumed that the frame time was almost constant. Then I took the average of the last 25 frame times and used that as my current. This smoothed out the inaccuracy of the crappy System.currentTimeMillis(). The downside is that it can give you speed up/downs, if you do not have constant fps.

Offline Murdockian

Senior Newbie

Java games rock!

« Reply #2 - Posted 2003-10-14 03:05:29 »

So, you still use System.currentTimeMillis() but filter the worst inaccuracy away by averaging the last 25 frames...

I guess there's only one way to check if it might work Wink Test!

Thanx, Markus
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline MGodehardt

Junior Devvie

why does the chicken cross the road?

« Reply #3 - Posted 2003-10-17 11:14:40 »

With System.currentTimeMillis

on Win98 you get max 10FPS

why because intervall min is 100ms ( because timer has 50ms ), thats a physical law twice the res is min sample. U learn this at university

DO NOT USE System.currentTimeMillis OR YOU ARE DOOMED.


Sell your game for 50 bucks with 10FPS and your customer will haunt u forever.
Offline Abuse

JGO Ninja

Medals: 64

falling into the abyss of reality

« Reply #4 - Posted 2003-10-17 11:28:49 »

I disagree.

So long as your render cycle takes less than 50ms, you won't miss any clock ticks, and you will achieve the maximum 19-20fps.

If you were sampling the time at random intervals, (hence you don't know when the current clock tick began) then yes, the maximum accuracy will be 10fps.
But, because you are performing a tight spin on system.currentTimeMillis() (waiting for it to change) you can be sure you sampled the timer almost immediately after it changed.

I don't dispute that 20fps is poo though ^_^
Offline Murdockian

Senior Newbie

Java games rock!

« Reply #5 - Posted 2003-10-17 12:00:31 »

I get the picture. I was just unsure of how currentTimeMillis was implemented...

BTW - Yes, MGodehardt I also recall the double frequency stuff from when I graduated a M.Sc in Computer Engineering, Mechatronical Systems and currently work / teach as a Ph.D student in sweden...

Some people study at university but still don't know everything about Java...

You learn as long as you live, otherwise it would be kind'a boring Wink

Pages: [1]
  ignore  |  Print  

EgonOlsen (58 views)
2018-06-10 19:43:48

EgonOlsen (40 views)
2018-06-10 19:43:44

EgonOlsen (60 views)
2018-06-10 19:43:20

DesertCoockie (239 views)
2018-05-13 18:23:11

nelsongames (141 views)
2018-04-24 18:15:36

nelsongames (140 views)
2018-04-24 18:14:32

ivj94 (882 views)
2018-03-24 14:47:39

ivj94 (143 views)
2018-03-24 14:46:31

ivj94 (794 views)
2018-03-24 14:43:53

Solater (158 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!