Best approach to deal with very similar projects with lot of shared code

Hi, the last time I posted here Defold still was a closed source. Congratulations :slight_smile:

Wishing your opinion on this. I was starting new project and experimenting with sharing code, or multiple projects sharing same space, someway…

I tried horrendous ideas like:

  • Having two game.project on the same place renaming the filename. Not possible. Bad idea.
  • Nesting two Projects, child project in a folder inside parent project :smile: Fail. Parent can access child scripts and assets, but URLs from the child project are no longer valid. (Almost baby!)

Of course I already knew the most sane approach making a extension (or module shared libraries), then using it from every project. Lot of nice things here but I think I can’t easily edit|modify the shared code from any of the projects. Only from the original. Upload to the repo then fetch from the others… as read-only.

Finally I decided to go with multiple Bootstraps Main Collections, because I’m just sharing the code with myself, between a few projects where most of the code (95%) will be shared stuff. And could be quickly edited from anywhere is being used. Then two switch projects I switch the Bootstrap Main Collection.

Most of the difference will be on the initialization, I don’t wish to use many conditionals on the initialization code. I wish to enjoy the fact that Defold only adds to the bundle the assets that are actually referenced, to strip assets from each project when they are not needed.

More specific real case ( and sorry to make you read so long to get here) is game with Mobile and Desktop versions, sharing lot of code, but the Desktop will have also Level editor functionality, more debugging code and heavier amount and resolution of assets. The desktop version will not care about the mobile resources, but the mobile game will have any desktop asset stripped out.

Thanks for you patient and please share if you could what you do in similar case?

Regards

1 Like

Your solution with different bootstrap collections should solve this fairly well I think. The desktop bootstrap collection could include a level editor collection and the game collection and load both. The mobile version would have only the game collection.

1 Like

Thank you @britzl. I’ll report later here how it was going that way.

1 Like