Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  how to monitor loading of ressources  (Read 1177 times)
0 Members and 1 Guest are viewing this topic.
Offline emzic

Senior Member





« Posted 2006-05-30 14:57:24 »

hello,

in my game i have a lot of ressources (textures, sounds, maps, models, etc...) which all need to be loaded before the main window should show up.

what is the best way to monitor and visualize the loading progress? should i run a separate thread and constantly check for changed variables?
thanks!

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Offline Ask_Hjorth_Larsen

Junior Member




Java games rock!


« Reply #1 - Posted 2006-05-30 17:10:04 »

Is there any problem with the 'obvious' solution of simply printing to standard out or updating some text component every time something has happened? For example, you could increment a counter for every resource loaded. It might not portray the time it is going to take very realistically, but when the user has run the application once or twice it'll be easy to see approximately how far it is into the loading process.
Offline emzic

Senior Member





« Reply #2 - Posted 2006-05-30 17:34:52 »

i am sorry, i forgot to mention that i want to watch the loading process from another part of the program. preferably in another thread, so i can display a nice progressbar.

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sequalit

Junior Member





« Reply #3 - Posted 2006-05-30 19:08:02 »

Use a implementation of MediaTracker for your image loading, when MediaTracker notifies that its done loading, then show the game.

here's a forum link for it
http://www.java-gaming.org/forums/index.php?topic=13420.0

api
http://java.sun.com/j2se/1.5.0/docs/api/index.html

tutorials
http://www.google.com/search?q=mediatracker%20tutorials&svnum=100&hl=en&lr=&safe=off&sa=N&tab=iw

while(gettingTired())
     crankOutMoreCode();
     if(asleep()){
          wakeUp();
          makeCoffee();
          chugCoffee();
     }
}

-Sequalit
Offline Mr_Light

Senior Member


Medals: 1


shiny.


« Reply #4 - Posted 2006-06-01 06:49:52 »

is the media tracker actually tracking madia yet and not just images?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Kova

Senior Member





« Reply #5 - Posted 2006-06-02 14:40:37 »

I haven't tried it yet, but NIO offers loading file data through buffers and such... maybe you should try that? It gives you insieght how much data was loaded, and you know from the start how much data needs to be loaded so you can create fine progress bar.
Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #6 - Posted 2006-06-03 02:01:50 »

Yes, I think MediaTracker wouldn't work with all files?

How about using URLConnection? With a thread, you can easy load data from the net and store it in a file + track progress. Something similar to:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
 // where to store the data
OutputStream out = new FileOutputStream(localFilePath);   

 // where the file is located we want to download
URLConnection urlConnection = new URL(remoteFileURL).openConnection();     
InputStream in = urlConnection.getInputStream();

// globals
totalSize = urlConnection.getContentLength();
currentSize = 0;
byte buffer[1024];
boolean finished = false;

while (!finished) {
    int size = in.read(buffer);
    if (size == -1) {
       finished = true;
    }
    else {
      out.write(buffer, 0, size);
      currentSize += size;
    }
}


It won't compile. There is also some stuff missing. However, that's what I basically use. With the class variables "currentSize"/"totalSize" you can track the download progress from a separate class. I can send you my "FileDownloader" class if you are interested...

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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (25 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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!