I was wondering if someone could give me some more information about packages in panda. From what I have read it sounds like OSGI.
so I have a couple questions:
Using the packages what is the best way to split up my code?( this is more of a software engineering/code design question)
How does my program run with the packages? are all my imports still correct or do I have to use a special import?
thanks in advanced
I don’t know if it exists the “best” way, I think this is a typical case-by-case scenario, so it should depend on your specific project.
For example, in my game I’ve packages for images, models, audio files, code, … So, (almost) all my code is in a single package. But I could imagine scenarios which contain more code packages, if the code is modular with parts which have different update frequency.
So, in short, I think the “key” idea is “modularity”.
No, the transition to packages is almost transparent. There are only some small differences about the path of some kinds of file which aren’t automatically imported in the model path, afaik.
Thanks for the reply, it was very helpful.
I read about the difference in file system when using packages, how did you get around it?
To anyone else, if you wouldnt mind sharing how you are packaging your project it would be helpful. I want to see what others are doing so that I can do this right the first time.
I’d add to my previous post that you could decide what to put inside a package using a metaphor from OOP: “tight internal cohesion” and “loose external coupling”.
For many type of files you needn’t modify anything, it’s transparent, for example this code is valid with or without packages:
loader.loadSfx( ... )
loader.loadModel( ... )
loader.loadTexture( ... )
loader.loadFont( ... )
and so on. You won’t see differences. Problems arises when you want to open other kinds of files e.g. xml ones, where you’ve to replace your
open( 'path/to/yourFile.xml' )
( ExecutionEnvironment.getEnvironmentVariable( 'YOURPACKAGENAME_ROOT' )
) + 'yourFile.xml'
Obviously you can put this inside a function or a specific context manager, which could handle this situation elegantly.
At the moment, I’ve this directory structure:
Every directory corresponds to a package (I build my package with that directory as “argument”).
fonts contains fonts (wow), hud, images and logos contain images of the corresponding “type”, models contains egg files (automatically translated to bams when you make the package), music, sfx and voices are foreseeable; src contains all the code but a main file contained in main (this way I can modify the code of the game (modifying files in src/) without (mostly) redistributing the installer because it only contains the invocation of src’s stuff, so the main’s stuff is unlikely to be changed).
The packaging itself is made using a SConscript file which invokes the ppackage commands.
Also with packages you can lock your assets with passwords to people “dont steal” your game art.
Beside imagine you thrown your game to people and two or three months after you expand your game with new quests, weapons, bugfixes, etc … then you can just include a new patch (package) to the game and people don’t have to reinstall all game again… this is quite useful in a webbrowser app.