Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: Ryex on June 10, 2009, 01:17:36 am

Title: Loading screen
Post by: Ryex on June 10, 2009, 01:17:36 am
I noticed that when you open any rmxp game the screen stays black for a while (like 10 - 20 seconds depending on you comp and how many scripts you have ect.) and i got to thinking "hey what if you put a script at the top of the editor that drew a loading text that stayed there until all the scripts had be loaded and what ever else it dose had happened so I made this. all i did was make a new script at the top of the editer and pot this in it


$loadingsprite = Sprite.new(Viewport.new(0, 0, 640, 480))
$loadingsprite.bitmap = Bitmap.new(640, 480)
$loadingsprite.bitmap.font.size, $loadingsprite.z, $loadingsprite.bitmap.font.color = 40, 5000, Color.new(255, 255, 255)
$loadingsprite.bitmap.draw_text(0, 0, 640, 32, 'LOADING...')
Graphics.update



it hardly advanced but the effect is interesting try it out, mess with it and enjoy!



I also played around with Graphics.frame_rate I set it to 120 frames per second and my cpu spiked to over 60% and the fps still didn't go over 58 frames per second. lol!
Title: Re: Loading screen
Post by: G_G on June 10, 2009, 01:48:23 am
You can even use a picture too which is pretty cool. Just replace this line
$loadingsprite.bitmap.draw_text(0, 0, 640, 32, 'LOADING...')

with this
$loadingsprite.bitmap = RPG::Cache.picture("picture name here")

Just import the picture into the Pictures folder
Title: Re: Loading screen
Post by: Blizzard on June 10, 2009, 05:30:53 am
10-20 seconds? O_o "Script is hanging" appears after 8 seconds of not calling Graphics.update. ._.
Title: Re: Loading screen
Post by: G_G on June 10, 2009, 05:32:39 am
maybe he meant frames :P
Title: Re: Loading screen
Post by: Ryex on June 10, 2009, 10:30:08 am
Quote from: Blizzard on June 10, 2009, 05:30:53 am
10-20 seconds? O_o "Script is hanging" appears after 8 seconds of not calling Graphics.update. ._.

ya ok I exaggerated it take about three seconds for scene title to pop up
Title: Re: Loading screen
Post by: fugibo on June 10, 2009, 10:46:20 am
Quote from: game_guy on June 10, 2009, 01:48:23 am
You can even use a picture too which is pretty cool. Just replace this line
$loadingsprite.bitmap.draw_text(0, 0, 640, 32, 'LOADING...')

with this
$loadingsprite.bitmap = RPG::Cache.picture("picture name here")

Just import the picture into the Pictures folder


NO! NO CACHE! You're only gonna load this image once, so there is absolutely no need to add the extra loading time and space of caching it. Just use

$loadingsprite.bitmap = Bitmap.new("Graphics/Pictures/<name_here>")


Also, don't forget to call $loadingsprite.dispose when you get to Main.

@Blizz: Not when you're loading it, since the engine is parsing the scripts, not loading running ruby (similar but separate; ruby_run() and rb_require_script("<name>"))
Title: Re: Loading screen
Post by: Zeriab on June 10, 2009, 10:51:52 am
When coming to main I would suggest using:
$loadingsprite.dispose
$loadingsprite = nil

That way the garbage cleaner will eat the disposed sprite when it feels like it.

@WcW: During that time the picture won't be displayed. It will only displayed while the "Script is hanging" error can occur.
Title: Re: Loading screen
Post by: Ryex on June 10, 2009, 12:05:49 pm
Quote from: Ryexander on June 10, 2009, 01:17:36 am

Graphics.update


that's why you put this right under creating the loading sprite otherwise it wont show until you reach main.

and ya i disposed the loading sprite when I got to main but I forgot to say that
Title: Re: Loading screen
Post by: Seox on June 10, 2009, 12:50:17 pm
Nice idea! Mind if I use it, with creds?

Thanks WcW and Zeriab, for preventing computer explosion.

^_^
Title: Re: Loading screen
Post by: fugibo on June 10, 2009, 12:57:22 pm
lol, I forgot to say the "= nil" part, even though that's not really as important as dispose (mainly just good for memory)
Title: Re: Loading screen
Post by: Ryex on June 10, 2009, 01:36:54 pm
Quote from: Seox on June 10, 2009, 12:50:17 pm
Nice idea! Mind if I use it, with creds?

Thanks WcW and Zeriab, for preventing computer explosion.

^_^


no need for credits this is hardly something work giving credit for.
Title: Re: Loading screen
Post by: Zeriab on June 10, 2009, 01:59:21 pm
The dispose ensures that the memory is freed pretty much immediately. (If you don't dispose your sprites you can easily get huge memory spikes)
Loosing the reference to the disposed sprite is good style so you don't accidentally mess around with a disposed sprite. (A huge number of errors can occur from messing around with a disposed sprite)

And no need for thanks ^_^
Title: Re: Loading screen
Post by: Blizzard on June 10, 2009, 02:09:59 pm
I agree on the last one. You don't have to ever combine "sprite != nil && sprite.disposed?" because it's never disposed. When it's not there, it's nil, end of story. xD