Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 1435 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?
Markus
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 Member




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.

IF U DO NOT FOLLOW THESE GUIDELINES DONT ASK ME

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

JGO Knight


Medals: 12


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 ^_^

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
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

/Markus
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!