How do you organize your complex/large projects?

Hi,

I want to learn how to organize and manage code/logic in GDevelop for large game projects.

==

I want to avoid pitfalls such as:

  • delays in changing between levels.
  • lag from opening/closing a universal pause menu.
  • long loading times, both for level to level transitions as well as during booting up the game itself.
  • performance problems that subtly stem from a use of a particular function or behaviour even if everything else was done sensibly to avoid lag.

==

So, I have a battery of questions to the more experienced users/devs of GDevelop:

  1. If you’ve made a large Gdevelop project before, whats the biggest mistake(s) you’ve made that you’d want to do differently in a future large project?

  2. When constructing your game to be as smooth as possible transition-wise from screen to screen (level to level, main menu to level, level to main menu, main menu to options menu etc), did you make the entire game as a single scene or is each screen seperate scene?

  3. Are your main menu, options menu and pause screens seperate scenes or do they all exist within the same scene(s) as your levels as addons?

  4. Do you know of any information resources, blogs, YT channels, guides or tutorials that show how to better organize more complex/larger projects for GDevelop?

  5. What are some subtle dev tricks you found in GDevelop that were useful in your later projects, like any little or big thing that made something to implement far easier, become more optimized or lead to better organization within your project?

  6. Are there any neat coding structures that you have used in your projects that improved/eased your ability to expand or maintain it long-term? (stuff like Model-View-Controller, MVVM, certain programming design patterns etc.)

  7. For performance reasons, do you use pooling when handling spawning/deleting of objects, for things like bullets, enemies, explosions etc?
    (By pooling, I mean pre-spawning everything in the level that the game will use in advance and simply hiding/showing it as needed instead of actually creating/deleting each entity.)

==

Any answers would be much appreciated and good info would help me or others browsing this thread to complete a big project much faster with better quality.

Thank you.

6 Likes

I didn’t create huge projects but I can defenitly answer the second question and that is: Use seperate scenes when creating menus and levels, especially if you make the game for Android or iPhone cause if you won’t, the game will lag a lot.

1 Like

@CorrectRain: Thank you,

How were the transition times though? Was there any delay (more than 1 second) when switching between scenes?

Did you use External Layouts or did you completely have your menu seperate from levels?

Something to keep in mind is that all resources are loaded at the start of the game. There isn’t (in most cases) selective loading, so scene switching should always be immediate unless something has gone wrong.

1 Like

@Silver-Streak : Thanks,

What do you mean by (in most cases), is there a way to override resource loading somehow?

What could cause something to go wrong that would cause noticeable delay scene switching?

No. (Edit: at least nothing that I’ve ever been aware of) But if you have an event that conditionally loads a URL resource, that web resource is only loaded at that time. Anything in the resources tab is mostly preloaded at game launch.

A while loop event at the start of the scene. Some sort of procedural generation that does calculations/generation at the start of the scene or before switching scenes, etc.

The actual scene switching itself shouldn’t be impacted by assets.

@Silver-Streak Ah ok, so former is about loading something external outside the game via web.

Latter is mostly if theres heavy processes placed up front in the scene as it begins. Ok.

That said, would it be faster to keep the entire game running in one scene and simply loading/unloading content/levels manually via events/code, rather than using the scene system to switch between levels?

I think from a game building perspective, it’s much faster (for you, the game dev) to have multiple scenes. Just so you’re not scrolling through hundreds of objects/events/etc by the end of the game.

I haven’t done a 1:1 comparison on switching to another scene vs deleting all objects in a group from external layout 1, and loading all objects from external layout 2.

One of the mistakes I made in my project was the “For each” event.
Try to avoid it as much as possible.
In my project there are many, many enemies spawning. When I had the “For each” condition attached to them the game will seriously lag when spawning at around 200 enemies.
When removing it, the game will be smoother.

@Silver-Streak Thanks, I see the concern in making the list of stuff becoming overwhelming. I’m willing to go through the effort of making a more robust foundation for the game even if it means more work though.

External layouts are essentially seperate scenes, so any objects would only show up if they’re loaded, which should cut down the total number of objects and events down to a minimum.

I’m considering going down the route of 1 primary game scene and many external layouts - trying to keep the critical core game systems always loaded, but swapping out surface level stuff via external layouts - hopefully that should lessen the amount of stuff being unloaded/loaded overall, thus resulting in better efficiency and smoother experience to the player.

–

@Mirquiso What would you use instead of the ‘For each’ event to achieve the effect you were aiming for?

@Mirquiso
HI, what is the “for each” alternative ?
I have the same performance problem but I’m not able to resolve it.
Thanks,
J

Simply dont use it unless really necessary. In my case, I thought I needed it but turned out it wasnt necessary. I use objects (enemies) with a Health/damage system, FireBullet extension and IsOnScreen.
So with the ForEach event, the game will lag when lots of enemies are involved, but without it, it will play out better.

Not a super experienced developer, but just having finished a 1 1/2 year project where many mistakes were made in the learning process, maybe something here would help:

  1. biggest mistake - Not using Global objects from the beginning. I didn’t figure this out until about half way through, and it was too late to change, but never again.
  2. scenes- def. separate scenes … so much easier to handle and implement.
  3. main, pause, options all separate. I actually didn’t do pause as separate in the beginning, and regretted it at the end.
  4. resources -haven’t found any really good ones out there yet. Lots of trial and error, really.
  5. Just be sure everything is in order. Even one small thing can lead to a weird lag if it is in the wrong step. I had a weird issue with the character moving a pixel for about 5 seconds after stopping, but only on my later levels. Turns out, it was were I had renamed the window title and had it one event below were it should have been that was causing it. Much hair pulling for a week over that one.
  6. neat structures - maybe to me, but I wouldn’t share them to be laughed at by more experienced people.
  7. prespawn- I had a number of enemy elements on each level. For some, I spawned groups based on player distance, which seemed to work well, deleted after player distance was greater than X, others I did not activate/animate until player distance was within X range. I did not notice any particular performance difference on my game for either, but other games may vary.

Hope something there can be helpful to someone. Biggest thing I think is just start, you will discover your own mistakes along the way for your particular style, but don’t be afraid to start without having the “perfect” plan in place from the beginning.

2 Likes

@snobunni
Thank you, this is valuable information. I some clarifying questions.

  1. Where would you use global objects and how?

  2. What problem did the pause screen cause for you to make you want it be seperate?

  3. Any structures are worth sharing, no matter how poor you consider them to be - this thread is intended for learning and studying, it needs that vital data how people have done things so there would even be any vantage point to see what could be more optimal. Please do share!

  4. How many enemies did you have on levels at most?

I’ve been chatting with the author of Hyperspace Dogfights and Red Tether - both large projects made in GDevelop and they gave me excellent clues in organizing a large game.

- The Shapeshifter Omni-Object Concept -

If I have hundreds of something (enemies, weapons, bullet types, hazards, obstacles) that more or less have certain common attributes (variables) and interactions (functions/behaviour), then those are possible to organize all as a single object but use the animation system(!) to determine what that object is meant to be at any given time whenever a new instance of it is spawned into the game.

The animation system for a sprite object can contain many hundreds of animations - some only need one line of animation, while others can have multiple entries of animation. Technically its also possible to keep every object’s animation frames within one line and simply change the frames manually through the event sheet.

To make this work in the code, effectively I have an action in the event sheet that will say it wants to spawn X object, so I will spawn this “omni object” or a “shapeshifting template object” however you wanna call it, then based on what I want to spawn I will tell the variables of this object to become the ones that this object is supposed to have. Then I have my object!

This is tremendously powerful for a lot of reason.

If you are familiar with the traditional coding term “Class”, then basically treat the objects in the right hand side list (scene objects) as Classes, instead of specific types of an object.

Just like with Classes, if I need to implement a new feature or alter a behaviour that affects all objects, I won’t have to edit hundreds of objects - I only need to change one.

I also have the ability to change one object into another one just like that, while maintaining any previous applicable conditions that this object had, like momentum or health - if I wanted to.

Best of all, the scene object list is not overwhelmed insanely where just scrolling or finding anything because awful. Instead, all the data for each weapon/item/projectile/enemy lives either in the events sheet or it can be externally loaded from xml/json files! (which btw can enable a stats-only based modding system too if you can set up your game to read external text files from a folder as new entities)

1 Like

Hi, Reactorcore! :wave::slightly_smiling_face:

It looks interesting and reminded me of a feature request of arthuro555 about “Object states”: Object "states" - #7 by davy

I like to do this with objects that do not have many animations and has helped me to better organize the project. On the other hand the objects that have many animations I do not like to put them all in one object, otherwise the animations window itself is that will get overloaded and confused instead of the list of objects. An important point is that Gdevelop does not allow us to place the animation of an instance that is in the scene by its name, only through its order. If you reorder the animations (perhaps to organize them) this may change the animations of some of these instances. And I think it helps more in the organization than in the performance of the game.

Just to chime in, while the idea of a base template object is definitely very powerful, for the most part you’re just replicating the Object Group functionality that is in the system.

There’s no negatives to the method you’re suggesting (other than potentially having some extra conditions in your events), but it is the same as just having multiple objects and throwing them into an object group, performance wise. (At least as far as I’m aware, anyway).

Not a problem, each animation can and should have a unique name when using this concept. I can thus reorder them as much as I please.

1 Like

Theres no way to collapse/expand the scene objects list (or pack them into subfolders) which will inevitably lead it to contain every single weapon, projectile, item, prop, background all in one monstrous loooong list. Scrolling that is a nightmare and may slow down GDevelop and my workflow considerably.

Maybe, but that is what object tags are for in the object list, allowing you to sort and filter objects.

It will still lead to the same or potentially less scrolling than you would have in the event list, since you will have considerably more conditions for every event.

Again, both methods are fine, but there isn’t a difference performance or workflow wise.