Cleaning up

Blitz3D Forums/Blitz3D Beginners Area/Cleaning up

Bankie(Posted 2006) [#1]
Hi, I've been using Blitz3D for just a few months and (probably amateurishly) I've been loading/creating all my resources (meshes, surfaces, textures, entities, etc) at startup and keeping them loaded the whole time.

Now, I want to start doing things in a tidier fashion. I imagine that what I should be doing is loading/creating resources on starting the game from the in-game menu, then destroying everything on game over.

However, Blitz seems to lack clean-up commands. I can delete entities, brushes and textures, but I can't free up meshes and surfaces. I can, however, use ClearSurface, so at least the mesh wouldn't be visible when the user is returned to the menu.

My simple question is: Do I just declare my meshes and surfaces on program startup and use ClearSurface as described above, or am I missing something and there's a way of freeing up meshes and surfaces?


Ross C(Posted 2006) [#2]
FreeEntity deletes a mesh :o)

If you really want to manage your resources, you should look at coding something of an engine. A piece of code, that handles say a level file and loads in everything it needs, based on that file.

Me personally, i'm creating a level builder and using the EntityName() command to attach instructions, so to speak for the entities. But this requires you to write a save routine for the format. Another way, would be to write a simple placement editor for your meshes, and save their locations and file paths. When loading in a level, you would load your text file in and the engine would read all the entity locations from that and position and create them.

About detroying everything. Blitz frees all the memory you use on either, exiting the program or calling the graphics command, OR using clearworld command. What you should be more concerned with, is keeping track of the entities you use, and make sure, fater freeing them, you set the variable used to keep track of it, to zero.


OJay(Posted 2006) [#3]
FreeEntity()

/edit: ah well...what ross said


Bankie(Posted 2006) [#4]
Thanks Ross, your reply was extremely helpful. ClearWorld looks to be the most simple way of cleaning up after game over. Storing levels in files is the way I've always done things. I usually have a game editor mode which saves the info to a simple file when I'm done. Although it takes a while to make the editor it saves time in the long run as well as making it more fun and intuitive to create the game data.