Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Angry Roach
19
Years of Service
User Offline
Joined: 21st Jan 2007
Location: Jinan, Shandong, China
Posted: 5th Nov 2011 15:18 Edited at: 5th Nov 2011 15:19
When the player dies, the game must unload the maps and variables, which not only causes some problems (an unresolved bug which is my fault), but it takes about a minute to unload the game. This will frustrate players. I'm looking for a simple solution: closing the program and then opening it again. Is there any way to do this in the code?
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Nov 2011 15:30 Edited at: 5th Nov 2011 15:30
You can use this code...



Both Execute File, and AppName$() are standard DBP commands.

But this is horrible and should be avoided in my opinion. It's best to solve whatever bug is causing the issue described and unload all resources manually.

My signature is NOT a moderator plaything! Stop changing it!
Angry Roach
19
Years of Service
User Offline
Joined: 21st Jan 2007
Location: Jinan, Shandong, China
Posted: 5th Nov 2011 15:32
Why is it so bad? Because it takes up too much memory?
Unloading the resources manually takes about a minute and playtesters said it was irritating.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Nov 2011 15:40
I couldn't comment without seeing your code.

Perhaps you should focus on optimising your media loading to minimise the amount needed?

Or your media handling to remove media no longer needed at runtime?

My signature is NOT a moderator plaything! Stop changing it!
Angry Roach
19
Years of Service
User Offline
Joined: 21st Jan 2007
Location: Jinan, Shandong, China
Posted: 5th Nov 2011 16:42 Edited at: 5th Nov 2011 16:45
But is it REALLY bad to use the execute app code? I understand the quick memory jump but is there another reason? I mean, I'll try to optimize the code, but I doubt it will make it much quicker. The gameworld is too dynamic and everything must be unloaded.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 5th Nov 2011 17:26 Edited at: 5th Nov 2011 17:31
Executing another program is most likely the same as loading new data with the same image, and object numbers as the last level anyway. So just try loading over them, and see what happens to the memory. I mean, addresses shouldn't really be stored for the old graphics unless DBPro for some reason decides to reserve those old addresses for something.

Maybe computers have changed since I last used assembly language. You used to have to store addresses else they were overwritten.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Nov 2011 17:53 Edited at: 5th Nov 2011 17:55
Why not just use the EMPTY ARRAY command or IanM's CLEAR ARRAY command to destroy all data in the arrays you use? If you want to get rid of images and objects loaded as well using SET DISPLAY MODE will erase all that.

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 5th Nov 2011 22:17
Quote: "using SET DISPLAY MODE will erase all that."

??? Wow!!! I learn something new everyday...

I've been using misc handling routines to clear everything that I've loaded or created too, and then that crops up...

I'll still do it my way though...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Nov 2011 23:15 Edited at: 5th Nov 2011 23:15
From what I remember, Set display mode doesn't clear everything properly, or something.

It erases the data, but not the references to it I think.

My signature is NOT a moderator plaything! Stop changing it!
Agent
21
Years of Service
User Offline
Joined: 7th Sep 2004
Location: Sydney, Australia
Posted: 6th Nov 2011 01:19
I can't see any reason why you'd want to do an actual, full reset of the program. If all you're doing is starting the program again (ie, a reset??), save time by keeping the necessary assets loaded, and just branch control back to the start of the program. Delete unnecessary assets on the fly, as they become unneeded.

Loading a second instance of the same program and immediately terminating the current instance seems crazy. Assets get unloaded anyway when you hit an END in the program (this is why the disk keeps accessing and the OS seems a little slow after you quit any resource-heavy program, including DBPro games), and the new instance of the program will have to load some or all of your resources again. Very messy.

Stick a REPEAT at the point of your code where you want to loop back to, and an UNTIL at the end of the code, the condition being a flag that you set when you want to trigger the reset. Then wrap the whole REPEAT UNTIL loop in another REPEAT UNTIL loop whose condition is a flag you set when you want to quit the whole program. Above the top layer loop is where you put your asset load instructions, and below it is where you put your asset unload code - or nothing, and your program will clean up after itself automatically on quit.

Quote: "If you want to get rid of images and objects loaded as well using SET DISPLAY MODE will erase all that."

Holy sh!t.

As soon as I read that, my mind went "That doesn't sound right, Groggy's gone nuts" and went immediately to test it. He's friggin' right - everything gets freed up when you issue a SET DISPLAY MODE.



This code throws an Image Does Not Exist error. Comment out the SET DISPLAY MODE command and the image displays just fine.

How irregular!

JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 6th Nov 2011 05:45 Edited at: 6th Nov 2011 05:46
@Angry Roach

Just trying to understand the real issue.

When the player dies, are you trying to restart your game and have everything start from the beginning, with all the variables reset, etc.?

And you are unloading all (or some) of the bitmaps and such and for a restart, reloading the bitmaps and all (or some) of the other assets that are loaded? Is this what is taking up time when you do a "restart"?
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2011 06:25
@ Mobiius:

It sounds crazy but everything gets cleared... including music and sound effects.


@ Agent:

Hahaha yeah, I went nuts long ago.

basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 6th Nov 2011 09:26
are you using sync when every object is loaded, or wait for all objects to be loaded then use sync?.
Angry Roach
19
Years of Service
User Offline
Joined: 21st Jan 2007
Location: Jinan, Shandong, China
Posted: 6th Nov 2011 09:40 Edited at: 6th Nov 2011 09:42
I knew set display mode unloads all images because it says it in the help file, but I don't think the help file says it unloads all objects, so I delete them all in a loop and unload all the arrays for every map in the game, which takes about a minute, significantly adding to the frustration after your character gets turned into hamburger meat.
I'm at the net bar and I still haven't had time to try any suggestions such as the empty array command and relying on set display to unload objects, but I will let you know tonight when I have time. Thanks!
@Mobius: Hopefully set display unloads it all properly.
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 7th Nov 2011 01:02 Edited at: 7th Nov 2011 01:03
@Angry Roach

I don't unload my models or graphics. I just hide them and turn collision off when they are blown up or die or whatever.

Then when I want to reset the program, I just reposition everything and "show" what I want to show.

When repositioning and showing everything is slow, I use a "mechanism" to obscure the fact of what is actually going on.

To give you an example, in a space game I might show doors closing and print "returning to portal" on the screen, while I'm actually resetting.

Hope this helps in some way.
Angry Roach
19
Years of Service
User Offline
Joined: 21st Jan 2007
Location: Jinan, Shandong, China
Posted: 9th Nov 2011 08:17
OK, set display mode works pretty well and I don't have to delete all the objects. Also, I had some embarassing inefficient code that I removed. Now it only takes about 3 seconds. Thanks.
Angry Roach
19
Years of Service
User Offline
Joined: 21st Jan 2007
Location: Jinan, Shandong, China
Posted: 11th Nov 2011 12:47
The bugs caused by unloading and reloading the game came from functions nested inside functions nested inside other functions. So now when the game reloads, I just set a new global variable to 1 and other globals are reset on the first frame after reloading.

Login to post a reply

Server time is: 2026-07-10 03:59:01
Your offset time is: 2026-07-10 03:59:01