Help check this idea

Blitz3D Forums/Blitz3D Programming/Help check this idea

Nack(Posted 2008) [#1]
Any coder would come to face this one day, its code organization. As project gets bigger and bigger, so does the type, functions and logic. I have been using types to manage my entities (mesh, sound etc) before, and that seems fine until the game structure change drastically during gameplay. For instance, in RPG, World exploration + Battle sequence. Same game, completely differnet in both style and structure.

This doesnt only happen in games, but application creation too. I am suure some of you can think of many scenario. Now what I propose is creating a "world" system. Before the program begins, user must create a world for objects, types, entites etc to be in.
So for instance:

nworld1 = createworld()
sphere = CreateSphere(nworld1)
cubechild = CreateCube(nworld1,sphere)

nworld2 = createworld()
cone = CreateCone(nworld2)

Each world cannot interact with another one. Only one world can be active at anytime. Any world that isnt active will be put to "sleep" and hidden to save memory and increase framerate. Collision will be switch off for the "sleeped" world and when one need to free all object in one world, simply delete the world.


Now I asked, possibly some experts out here, would this idea be feasible? I just happen to thought of it, and seems to me be feasible. Any flaw in this logic?


*(Posted 2008) [#2]
its easier to save the state of the world, positions etc to save everything as seeing as one world is active at any one time just load in the world thats required at that time. This is what all the loading screens etc are about in all games they are just loading in the next level/world for you to explore. If you had every world there at the start it would require so much ram etc that it would be unfeasable.


Ross C(Posted 2008) [#3]
What i do, is set most of the things up in a modeller. I personally now use Gile[s]. Create a pivot for each level piece, and name it accordingly. "<level=1> <piece=1>"

Then when loading the whole mesh into blitz, i simply loop through all the children, collecting information from the mesh names, and load these into type collections, performing different tasks. EntityName is a very useful and powerful command.


John Pickford(Posted 2008) [#4]
Just parent everything each world to a pivot and keep that pivot hidden when not in use. You could even write a bit of code which makes sure only one world pivot is active at any given time.


Gabriel(Posted 2008) [#5]
I completely disagree with Edzup, the last thing you want is to have to load a new world at the beginning and end of every random battle in an RPG. I'd do it John's way. If you're really worried about things getting confused ( perhaps if you were to use a physics engine at some point in the future ) then you could always just shift everything way off on the Y axis and shift it back when required. So the active world is parented to a pivot at 0,0,0 and the inactive world is parented to a pivot at 0,-5000,0 or something like that. Way down beneath the ground, where it couldn't interfere with anything even with a physics engine active*.

* Some physics engines have the ability to run multiple worlds anyway, but I don't think they all do. I know Newton does, and I don't think Tokamak does. Not sure about the others.


_33(Posted 2008) [#6]
oops, no comment.