Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  So how would you guys implement a loading screen?  (Read 4859 times)
0 Members and 1 Guest are viewing this topic.
Online Longarmx
« Posted 2012-04-13 02:41:52 »

Hi again everyone!

So, when your game is loading up, there is sometimes a loading screen so you don't have to look at a blank screen while it is loading up. You would usually have a loading bar that updates when a task in your loading process finishes. I don't know if I should make a new thread for the loading screen or just draw it over everything until the game is all loaded. Huh

If anyone has done something like this or has any idea on what I should do, then that would be great!  Wink

Thanks,
Longarmx

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #1 - Posted 2012-04-13 02:51:59 »

For this, you should load all your resources on a different Thread, and poll the progress of it.

Offline davedes
« Reply #2 - Posted 2012-04-13 03:02:29 »

It could also be done on the same thread -- just update the progress bar GUI, then load the next resource, and repeat.

In terms of design, it will probably take a bit of refactoring if you haven't organized your resource management at all.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tberthel
« Reply #3 - Posted 2012-04-13 03:17:23 »

polling is usually bad.  Instead just send an event to the loading screen when the resources for it are ready.

Online Longarmx
« Reply #4 - Posted 2012-04-13 05:03:51 »

Thank you everyone for your quick replies! I think that I will try to make it on the same thread, and then just update the loading bar when it reaches a certain point.

Thanks,
Longarmx

Offline ra4king

JGO Kernel


Medals: 336
Projects: 2
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2012-04-13 05:07:57 »

I support the use of polling. I prefer the idea of loading the resources in a different thread while the main game loop thread updates a loading bar based on how far the loading thread has completed.

Offline _Al3x

Senior Member


Medals: 7


Indie Games FTW!


« Reply #6 - Posted 2012-04-13 05:33:05 »

What I'm curious about is how to determine the progress of the progress bar (lol). I mean, do you take, for example, all the resources you'll load, let's say 120 between images and sounds, then you'll do 120 items / 100 % = 1.2, thus when loading one resources incrementing 1,2 of the progress bar??

I just realize that would be actually a good idea, right?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   private void loadEverything(){
      int incrementFactor = cantResources / 100;
      for(int i=0;i<cantImg;i++){
         loadImage("image"+i+".png");
         incrementProgressBar(incrementFactor);
      }
      for(int i=0;i<cantImg;i++){
         loadSould("sound"+i+".wav");
         incrementProgressBar(incrementFactor);
      }
   }


Edit: Added incrementFactor Smiley

Offline ra4king

JGO Kernel


Medals: 336
Projects: 2
Exp: 5 years


I'm the King!


« Reply #7 - Posted 2012-04-13 06:01:50 »

Or you do that calculation when you draw it on the screen. Here you simply increment the variable by 1.

Offline davedes
« Reply #8 - Posted 2012-04-13 07:36:42 »

Ideally it would be more like:
(with less verbose naming...)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
//the size of our progress bar component
int width, height;

//e.g. 3 images loaded out of 10, 30% finished
float progress = resourceManager.getLoadedCount() / resourceManager.getTotalResources();

//draw the "fill" bar stretched horizontally
progressBarFill.draw(x, y, progress*width, height);

//draw the outline so the user knows how much is remaining...
progressBarOutline.draw(x, y, width, height);

Offline Danny02
« Reply #9 - Posted 2012-04-13 09:03:35 »

nah, you just would call directly the progress ( in %)

you don't want to have the implementation how to calculate the progress in the open.
perhaps later you want to calc the progress relative to the file size of each resource and then perhaps give some hard to load resources a stronger weight.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline R.D.

Senior Member


Medals: 2
Projects: 1


"For the last time, Hats ARE Awesome"


« Reply #10 - Posted 2012-04-13 09:43:16 »

Just use a xml which has all the paths and names for the images and load them deferred Smiley After that I load them normally via a List which has all the deferred resssources and on render I show that in a nice big bar Shocked
This whole stuff does not happen in a different Thread... Why should I there is no reason because I just have images and some sounds. all 2D Smiley
Offline ReBirth
« Reply #11 - Posted 2012-04-13 13:28:30 »

Or in noob way
1  
2  
3  
4  
5  
//set display to loading screen
while (!done){
//load some stuffs
//update progress by one step
}

Offline gimbal

JGO Knight


Medals: 25



« Reply #12 - Posted 2012-04-17 17:59:27 »

Or in noob way
1  
2  
3  
4  
5  
//set display to loading screen
while (!done){
//load some stuffs
//update progress by one step
}


Actually would be my preference if only a loading bar is displayed. But as soon as you need to show something else moving around it don't work so great anymore Smiley
Offline ReBirth
« Reply #13 - Posted 2012-04-17 18:01:51 »

Loading animation? update it per frame on each step progress Grin

Offline SkyAphid
« Reply #14 - Posted 2012-04-17 21:43:44 »

I just have the room manager draw a black rectangle over the screen until each object is ready for rendering; along with a little something in the bottom corner that moves so the player knows it's working.

That's just my over-simplicity talking though.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
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.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (20 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!