Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,403 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
LBGUI progress bar #377689
07/15/11 16:12
07/15/11 16:12
Joined: Jul 2011
Posts: 15
C
Coover Offline OP
Newbie
Coover  Offline OP
Newbie
C

Joined: Jul 2011
Posts: 15
hi,

i wanted to make a progressbar for my game.
Because i use LBGUI i used the LBG_progressbar but it just updates the progress when the leven is loaded 100%;

Code:
void on_level_event(percent)
{
   lbg_splash_progressbar.progress = percent;
   LBG_update_progressbar(lbg_splash_progressbar);
   if (percent >= 100) 
   {
 	loaded_level.ready	= 1;
   }	
}



any idea how to fix that?

Re: LBGUI progress bar [Re: Coover] #377691
07/15/11 16:26
07/15/11 16:26
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
First of all, in Lite-C you have to define the type of each parameter, so it has to be
void on_level_event(var percent)
(It seems that the example in the manual doesn't write the "var" either. This seems to be an error at converting the code from Lite-C. Even if the compiler accepts your code without the "var" I do recommend not to ommit it.)

I guess you set on_level = on_level_event; right? on_level is only executed BEFORE the level is fully loaded, so the last value you get isn't 100, but rather 99.9 or something like that.
You have to define a function for on_level_load, which executes the code in your if (percent >= 100) block. Then it should work. And I also recommend to let that function execute on_level_event(100);

Re: LBGUI progress bar [Re: Coover] #377694
07/15/11 16:51
07/15/11 16:51
Joined: Jul 2011
Posts: 15
C
Coover Offline OP
Newbie
Coover  Offline OP
Newbie
C

Joined: Jul 2011
Posts: 15
thx for your help.

i changed the code like that the first is the on_level_laod event and the other the on_level event

Code:
void on_level_load_event()
{
	loaded_level.ready	= 1;	
}
void on_level_event(var percent)
{
   lbg_splash_progressbar.progress = percent;
	LBG_update_progressbar(lbg_splash_progressbar);
}



dont work


Last edited by Coover; 07/15/11 16:55.
Re: LBGUI progress bar [Re: Coover] #377696
07/15/11 17:05
07/15/11 17:05
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
To be exact, this is what I had in mind:
Code:
void on_level_event(var percent)
{
	lbg_splash_progressbar.progress = percent;
	LBG_update_progressbar(lbg_splash_progressbar);
}
void on_level_load_event()
{
	on_level_event(100); // To make sure it actually hits 100%
	loaded_level.ready = 1;	
}



But I'm not sure if I understood your initial problem correctly. Is it that the level gets never "ready" or that the progressbar just "jumps" to 100%?
If it was the first, it should now actually be solved.
If it was the latter one, this might be because maybe your level doesn't need long enough to be loaded? It only updates the progress once per frame, so if it is loaded within one frame, the progressbar will jump from 0 to 100 in that frame. You could try implementing a counter in your event function to see how many frames it takes to load the level. If it is just one frame or so, I guess there is no solution, but it will work better for bigger levels. Else, it must be an other problem.

Re: LBGUI progress bar [Re: Lukas] #377697
07/15/11 17:14
07/15/11 17:14
Joined: Jul 2011
Posts: 15
C
Coover Offline OP
Newbie
Coover  Offline OP
Newbie
C

Joined: Jul 2011
Posts: 15
The problem is, that it stays on 0% til the level is ready.
then it is 100%.
I stored the count of frames in a var and it tells me that the event is executed 5 times.
I tried to change it in anotehr part of the code and tehre i always have to wait one frame til its updated maybe thats the problem?

Re: LBGUI progress bar [Re: Coover] #377699
07/15/11 17:42
07/15/11 17:42
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
First, I just checked something and found out that the line
LBG_update_progressbar(lbg_splash_progressbar);
is totally unnecessary. This is not directly related to your problem, but updating the progressbar at this point is bad for the performance.


I don't know what you changed, but if it makes the event only be executed once, it may indicate that your level does need only one frame to load and the event was executed more than once per frame for some reason. But I can only guess that, because I don't know what you changed.

Re: LBGUI progress bar [Re: Lukas] #377714
07/15/11 19:12
07/15/11 19:12
Joined: Jul 2011
Posts: 15
C
Coover Offline OP
Newbie
Coover  Offline OP
Newbie
C

Joined: Jul 2011
Posts: 15
i have this
Code:
void on_level_event(var percent)
{
	lbg_splash_progressbar.progress = percent;
	LBG_update_progressbar(lbg_splash_progressbar);
        frame++;
}
void on_level_load_event()
{
	on_level_event(100); // To make sure it actually hits 100%
	loaded_level.ready = 1;	
}



then i hit tab and typed frames and he told me 5 and in the manual it says taht the on_level event cant be excuted several times in one frame

Re: LBGUI progress bar [Re: Coover] #377722
07/15/11 19:38
07/15/11 19:38
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
You still have the LBG_update_progressbar in your code. You can remove it.

There is an other possibility that came into my mind. Maybe you this isn't the first time you load a level? In that case you have to compare the value of the frame variable before and after you loaded the level. The difference of those values is the actual number of frames the engine needs to load your level.

Re: LBGUI progress bar [Re: Lukas] #377724
07/15/11 19:49
07/15/11 19:49
Joined: Jul 2011
Posts: 15
C
Coover Offline OP
Newbie
Coover  Offline OP
Newbie
C

Joined: Jul 2011
Posts: 15
i laod it two times cause its multiplayer game with anet and i started client/swerver mode but i have a wait after the first time and there i looked for the value 5-7 frames but no change of the progressbar

here the progress bar code
Code:
lbg_splash_progressbar = LBG_create_progressbar (NULL, screen_size.x*0.25, screen_size.y*0.9, screen_size.x*0.5, 1, 1, screen_size.x*0.25, 4, "%.0f%%", LBG_pbmaps(progress_left_tga,progress_middle_tga,progress_right_tga,progress_bar_tga), PBF_SHOW, 100, 5);
	wait(1);// wait und update müssen damit 0 angezeigt wird sonst ganzes bild in voller größe
	LBG_update_progressbar(lbg_splash_progressbar);



Re: LBGUI progress bar [Re: Coover] #377807
07/16/11 13:49
07/16/11 13:49
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
So it took only 7-5 = 2 frames? That means ideally it would go 0->50->100. But it could also go 0->99->100 or 0->1->100.

To check that, you can add this line
error(str_for_num(0,percent));
to the on_level_event function. Then it will show you the progress in messageboxes.

Page 1 of 3 1 2 3

Moderated by  aztec, Blink, HeelX 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1