Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  
  GAGE Engine Early Access  (Read 3142 times)
0 Members and 1 Guest are viewing this topic.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Posted 2003-04-01 02:15:22 »

Hi guys. I know I've dropped a few hints over the last week about a really cool gaming engine I've been working on. Well, now I'm going to drop some code. A (rather austere)  site has been set up for my engine, tentativaly named GAGE - Genuine Alternative Gaming Engine. Currently, the GAGETimer and GAGESound APIs are online for public review and consumption.

Please be aware that GAGESound is currently bare-bones and lacks a few features like volume contol. None the less, don't let that stop you from checking it out and letting me know what you think! Also, could someone use the GAGETimer on an OSX system and find out the resolution? I believe that OSX should provide 1ms resolution, but I can't be sure until someone trys it.

I'll post here when new releases are available. Check it out at:

http://java.dnsalias.com

Java Game Console Project
Last Journal Entry: 12/17/04
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #1 - Posted 2003-04-01 03:41:28 »

Mac OS X
getClockTicks()=0
getResolution()=9
getTicksPerSecond()=111


Not exactly what I was expecting... probably a rounding error and it should be resolution of 10?

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #2 - Posted 2003-04-01 03:47:32 »

Quote
Mac OS X
getClockTicks()=0
getResolution()=9
getTicksPerSecond()=111


Not exactly what I was expecting... probably a rounding error and it should be resolution of 10?


Errm... No, it finds the resolution through a hard loop that watches for the clock change. Did you run it more than once? (Just in case the JVM was starved for CPU)

Java Game Console Project
Last Journal Entry: 12/17/04
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #3 - Posted 2003-04-01 12:06:37 »

uh.. no I didn't.. I assumed the classes would be written to try to account for such variables with a long enough loop and averaging and jitter detection etc... Otherwise how are we supposed to use it if the results are so different every time??

E.g. here is the second run:

Mac OS X
getClockTicks()=0
getResolution()=16
getTicksPerSecond()=62

BIG DIFFERENCE, Let's try again...

Mac OS X
getClockTicks()=0
getResolution()=5
getTicksPerSecond()=200

WHOA!

Me thinks this code needs some tweaking...

got the 5/200 result several times in a row now.. ulp.. now I got 6/166
A few more 5/200's, a 6/166, oh a new one 4/250...

If possible those methods should be tweaked so they are more consistent..  or at least document how they should be used to get an accurate result.



Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #4 - Posted 2003-04-01 12:34:26 »

I should probably make it recalc more than once for accurate results. The problem seems to be in the JVM and classloader which is starving the thread that does the time figuring. As best I've been able to test, the routine works fine under the Sun VM, so I'm going to say that it's probably a MacOSX specific issue. Glad I asked for testing. :-)

I'll let you know when I have new code up.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline mattocks

Senior Newbie




Java games rock!


« Reply #5 - Posted 2003-04-01 21:30:36 »

How are you calculating resolution?

Are you exercising HotSpot enough to force it to compile the code? I've read that this requires at least 1000 calls to a method. How about something like:

// Error expected in measured elapsed time in nanoseconds
public long getResolution()
{
     final byte NTIMES = 10;
     long t1, t2;
     long dt = 0L;

       // Warm up JIT/HotSpot compiler
     for (short s=0; s<3000; ++s)
           t1 = getCounter();

       for (byte b=0; b<NTIMES; ++b)
       {
           t1 = getCounter();
           t2 = getCounter();
           while (t1 == t2)
                 t2 = getCounter();
           dt += (t2 - t1);
     }
         return dt/NTIMES;
}

- Craig
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #6 - Posted 2003-04-01 21:58:19 »

Here's the exact code (which is included in the download BTW):

1  
2  
3  
4  
5  
6  
7  
8  
9  
static
{
    long time = System.currentTimeMillis();
    long prev_time = time;

    while(time == prev_time) time = System.currentTimeMillis();
           
    resolution = time-prev_time;
}


The concept is that this hard loop will note exactly when the timer changes and calculate the difference between the previous number and the current number. The problem is that it won't work right if the thread is starved for time, say because the JVM is still loading in the background. Thus, I'm going to move the code out of a static clause and have it run inside the program thread. This may not solve the problem, but it's a good start.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #7 - Posted 2003-04-02 00:09:28 »

/me wonders why there isn't a
System.getTimerResolution();
Roll Eyes

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #8 - Posted 2003-04-02 02:04:56 »

you should run that in a loop until the result returned is consistent for a few iterations.

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #9 - Posted 2003-04-02 03:27:36 »

Okay, a new version of the timer code is up. Let me know if it works any better.

And for everyone who's been just dying to try it, the GAGE2D API is now available for download. It's still in early stages, but it already covers more than just about any other 2D API I've ever used. Some existing features:


  • Any level Parallax map scrolling
  • Automated collision detection of sprites
  • Management of game "missles"


Features planned:


  • Arbitrary Collision Map support
  • AI routines
  • Other nifty features that people request! Grin


As always, the download contains full JavaDocs, example code, source, and JAR files.

Go get it at:

http://java.dnsalias.com


An example game that pulls all the APIs together, will be available as soon as I clean up my code. Wink

Java Game Console Project
Last Journal Entry: 12/17/04
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #10 - Posted 2003-04-02 12:21:36 »

Much better!

Now it consistently reports:

Mac OS X
getClockTicks()=0
getResolution()=1
getTicksPerSecond()=1000

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #11 - Posted 2003-04-02 12:29:31 »

Excellent! And Macs even manage to give a full 1000 ticks per second! I knew I liked those machines for a reason... Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #12 - Posted 2003-04-02 13:00:56 »

Full JavaDocs for all APIs can now be viewed directly online. As usual, go to http://java.dnsalias.com and click on the JavaDocs link in the corner.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline mattocks

Senior Newbie




Java games rock!


« Reply #13 - Posted 2003-04-02 23:42:03 »

> Excellent! And Macs even manage to give a full 1000 ticks per second!
> I knew I liked those machines for a reason... Smiley

My Mac OS X native C timer gives a resolution of about 1100 nanoseconds (1.1 microseconds = .0011 milliseconds).

When I use it in Java via JNI, the resolution is about 1500 nanoseconds, so I lose 300-400 nanoseconds going across the interface.

Note that your resolution algorithm does not adequately "warm up" HotSpot, so the code will not be forced to compile (it will be interpreted).  When using System.currentTimeMillis() on the Mac this is not an issue since the apparent JVM timer resolution is 1 millisecond, but if you used a native timer you would obtain inconsistent results.

Are you planning to build in native timer support in future releases?

Craig
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #14 - Posted 2003-04-03 00:59:16 »

Quote
When I use it in Java via JNI, the resolution is about 1500 nanoseconds, so I lose 300-400 nanoseconds going across the interface.


Honestly, for the purpose of games, is the extra 300-400 nanoseconds that important? 1000 ticks per second should be more than enough to time a hundred or so frames per second.

Quote
Note that your resolution algorithm does not adequately "warm up" HotSpot, so the code will not be forced to compile (it will be interpreted).  When using System.currentTimeMillis() on the Mac this is not an issue since the apparent JVM timer resolution is 1 millisecond, but if you used a native timer you would obtain inconsistent results.


I'm not quite sure what you mean here. If the HotSpot compiler doesn't think it should be compiled, then there's a good bet that it doesn't need to be. SWPalmer has stated that he's now receiving 1 ms resolution, so I'm not sure what the problem is. Do you get different results?

Quote
Are you planning to build in native timer support in future releases?


Well, I don't have a Mac (yet), so I can't create one. But if someone out there has the time and the need, I'd happily accept a donation. Smiley All you need to do is to implement the NativeTimer interface and add your timer to be checked in the init() code of AdvancedTimer. You can look at the windows timer for an example.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline mattocks

Senior Newbie




Java games rock!


« Reply #15 - Posted 2003-04-03 02:05:17 »

> Honestly, for the purpose of games, is the extra 300-400 nanoseconds
> that important?

No, that was the difference between C resolution and Java resolution using my native timer.

> 1000 ticks per second should be more than enough to time a
> hundred or so frames per second.

Good point, especially since the thread resolution is not very accurate. Perhaps a more experienced game programmer than I could coment?

1500 nanoseconds => 1/(1500 * 10^-9) = 666,666 ticks per second

> I'm not quite sure what you mean here. If the HotSpot compiler
> doesn't think it should be compiled, then there's a good bet that it
> doesn't need to be.

From what I've read, HotSpot compiles methods that are called more than 1,000 times or so. Calling a timer once (interpreted mode) will give you a much slower response (larger time resolution measurement) than calling it thousands of times (compiled mode) and averaging the results. I find a speedup in performance of 20x (interpreted/compiled ratio), which is significant.

> Well, I don't have a Mac (yet), so I can't create one. But if someone out
> there has the time and the need, I'd happily accept a donation. Smiley

I'll try this when I get some spare time.

Nice work!
Craig
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #16 - Posted 2003-04-03 02:24:08 »

[size=3]--- BEGIN ANNOUCEMENT ---[/size]

The first demo of the complete API is online and it's a side scrolling Shoot'em up. Go get it!

http://java.dnsalias.com

[size=3]--- END ANNOUCEMENT ---[/size]

Quote
1500 nanoseconds => 1/(1500 * 10^-9) = 666,666 ticks per second


Hmm... The evil timer!  Tongue

Quote
From what I've read, HotSpot compiles methods that are called more than 1,000 times or so. Calling a timer once (interpreted mode) will give you a much slower response (larger time resolution measurement) than calling it thousands of times (compiled mode) and averaging the results. I find a speedup in performance of 20x (interpreted/compiled ratio), which is significant.


It *would* be significant if the timer actually did anything. Since the interpreted vs. compiled difference for this code is about a few native instructions per method, warming up HotSpot won't do much. The real problem with measuring the resolution was that the classloader ran in a low priority thread.

Thanks for your comments! Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline zparticle

Senior Devvie




Thick As A Brick


« Reply #17 - Posted 2003-04-03 11:35:24 »

For those that don't want to figure out how to run it.

cd to the bin directory and type (for windows)

java -cp Shooter.jar;..\lib\gage2.jar;..\lib\Resources.jar;..\lib\sound.jar;..\lib\timer.jar Shooter

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #18 - Posted 2003-04-03 11:48:38 »

Or you could just run:

java -jar Shooter.jar

Sorry, I though everyone would catch on to that one. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline mbishop78

Senior Newbie





« Reply #19 - Posted 2003-04-03 12:58:26 »

Pretty solid.  Sound lags a bit, but the timing and everything seems OK.

Michael Bishop
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #20 - Posted 2003-04-03 13:12:07 »

Quote
Pretty solid.  Sound lags a bit, but the timing and everything seems OK.


Thanks for testing! Can you give a bit more info on the sound lag? Does it seem to pause when a sound is played or does the action happen, then the sound plays a half second later? What type of sound card are you using?

I'm still trying to track down occasional pauses on some machines that seems related to sound (GC has not been a problem), so if anyone notices anything, speak up! Gotta shake out the bugs. Smiley

Thanks,
Jerason

Java Game Console Project
Last Journal Entry: 12/17/04
Offline kalleh

Senior Newbie




Java games rock!


« Reply #21 - Posted 2003-04-03 15:53:32 »

After taking a look at the API, I started a discussion at the JOSRTS forums:

http://www.josrts.org/cgi-bin/ikonboard/ikonboard.cgi?s=ed8bf91562d37c5bce7f17e0c5f86d7e;act=ST;f=2;t=200

For the sake of less complexity, development speed and ease of coding, I've proposed a game API library change, it will be interesting to see what direction the discussion will take.

Cheers

Kalle
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.

rwatson462 (30 views)
2014-12-15 10:26:44

Mr.CodeIt (23 views)
2014-12-14 20:50:38

BurntPizza (50 views)
2014-12-09 23:41:13

BurntPizza (84 views)
2014-12-08 05:46:31

JscottyBieshaar (45 views)
2014-12-05 13:39:02

SHC (59 views)
2014-12-03 17:27:13

CopyableCougar4 (57 views)
2014-11-29 22:32:03

toopeicgaming1999 (123 views)
2014-11-26 16:22:04

toopeicgaming1999 (114 views)
2014-11-26 16:20:36

toopeicgaming1999 (32 views)
2014-11-26 16:20:08
Resources for WIP games
by kpars
2014-12-18 11:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 23:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 23:36:02

List of Learning Resources
by Longor1996
2014-08-16 11:40:00

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

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

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

List of Learning Resources
by SilverTiger
2014-07-31 17:29:50
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!