How do you organize your projects?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

How do you organize your projects?

Post by Gunroar:Cannon() »

After roaming to and fro the land I've come across certain ways people do projects (from looking at various codes) and these are the categories I've seen (all terms made up)...

1) Chicken-scratch style (this could be named better...): Very simple structure that uses the minimum amount of files. Most things are done in main.lua, nice to have a quick start though may be a big pain to grow/add more stuff to it. Lacks OOP most of the time.

2) Everything but the kitchen sink (What I mostly use... kind of ... I should probably stop using it): There is some more structure to it, bunch of folders loosely separating types and a lot of downloaded stuff is thrown into one big lib/tools folder for use later. Main.lua is used mostly for requiring things. Can handle growth, but sometimes heedless edits to the large amount of files could make the project not reusable for another. Not even the libs (atleast when I do it :rofl: . I check the libs I edit can be edited and change a bunch of stuff to fit the project at hand). This could lean to be more favourable of a looser Chicken-scratch design or more favourable of "It's a machine".

3) It's a machine (Best name I could think of): Folders are separd strictly. There seems to be a whole game engine inside the game engine (/framework). It seems everything could be reused. Most times these kind of projects are guilty of having an src folder. Like a perfected form of "Everything but the kitchen sink" . Though some time might be needed to build up the base it ...should be reusable? (I never use this clean style so I don't know :P )


Of course these aren't strict rules or anything, just how my brain classifies a project with a glance at it's architecture.

I have 3 constant classes. A global "game" instance of a Game class that handles switching states, getting images; a mainMenu table that handles all menus and when the come up, etc and a media class that handles the playing of music. This could probably be done more efficiently but I'll learn better method as I go.

Do you build these mini-engines inside the projects/have one you've already built for use? Or do you have large projects that use a simple structure? Or something else?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 509
Joined: Wed Oct 05, 2016 11:53 am

Re: How do you organize your projects?

Post by MrFariator »

In terms of file structure, on the top level I have two main folders: content and lua (image). The content folder contains, well, content, things like audio, assets, internationalized string files, cutscene scripts, etc. Lua folder on the other hand, has the main game logic, like game object class definitions, various specialized classes (AudioManager, GameObject Manager, Map Manager, UI code, etc), and various other things. Any libraries the game use are under lua/libs, naturally.

There are couple other folders, debug and demo, and they basically contain what they say: files relating to debugging libraries or files, and files that define how the project should play while in "demo mode". These are automatically discarded when making shareable builds.

As far as how it all plays together it's basically your third option. GameObject Manager spawns, updates and makes the calls to draw game objects, Map Manager draws and updates the map, Texture Manager handles loading and unloading of textures, Audio Manager plays sound effects and loops music, various other classes keep track of cutscenes, dialogue, current level progress, any story or gameplay flags, and so and so forth. The main loop basically just calls these in specific order from tick to tick, and they do things based on the current game state.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: How do you organize your projects?

Post by Gunroar:Cannon() »

:ultrashocked: Structure... for images and sounds I just have one assets folder (and folders under that too).
And I see that it's common to call all methods from a game manager of sorts but I follow the route of using Hump's gamestate and an option that *kind of* overwrites all the love callbacks (Don't look at me like that :brows:) if there are functions with the same name in the state (which is just a class instance)

MrFariator wrote: Fri Jan 21, 2022 1:15 am
There are couple other folders, debug and demo, and they basically contain what they say: files relating to debugging libraries or files, and files that define how the project should play while in "demo mode". These are automatically discarded when making shareable builds.
Ahh, I like this, never heard of these things. Seems like a cleaner way of having one variable doDebug or DEBUG or something and setting it to false or true depending on whether it's about to be "released" for someone else to view.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
MrFariator
Party member
Posts: 509
Joined: Wed Oct 05, 2016 11:53 am

Re: How do you organize your projects?

Post by MrFariator »

It's something akin to preprocessing, but simpler. I don't use any fancy extra compilers or tools to do that preprocessing, it's mostly just my build script (a batch file I wrote for Windows, haven't gotten around to doing the same for linux or OSX) knows what folders and files to ignore when zipping and fusing the executable. As such, there will still be some code paths that might check against some specific debugging flag, but they either don't exist (due to the files that define being omitted), or are automatically turned into NoOP functions during initialization.

For a more sophisticated solution, you can look at LuaPreprocess.
User avatar
Hugues Ross
Citizen
Posts: 85
Joined: Fri Oct 22, 2021 9:18 pm
Location: Quebec
Contact:

Re: How do you organize your projects?

Post by Hugues Ross »

Do you build these mini-engines inside the projects/have one you've already built for use? Or do you have large projects that use a simple structure? Or something else?
These days, I go with whatever feels healthy. This usually means starting out with "chicken-scratch" for maximum iteration speed, then gradually evolving the structure into something more organized as the design solidifies and the project grows in size and complexity.

I don't typically end up with OOP or anything over-architected though, I used to be a lot pickier but I found that for me the benefits didn't make up for the cost.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: How do you organize your projects?

Post by Gunroar:Cannon() »

Ahh, chickens are good for speed but at one stage of I use that and want to make it bigger I end up having to spend quite some time converting it to something more organized.
For me OOP is king. ECS is just like a type OOP implementation to me.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Ross
Citizen
Posts: 97
Joined: Tue Mar 13, 2018 12:12 pm
Contact:

Re: How do you organize your projects?

Post by Ross »

For quick tests, experiments, or simple utilities, I start from scratch and only add what I need.

For "real" projects I have a fair bit of reuseable "engine" code. That has its own git repository and I use a git submodule to add it to each project. Then there are a few other one-file libraries which are more project-specific that I copy around as needed.

Recently I did try the chicken-scratch method for a more serious project just to make sure I wasn't losing contact with reality, but that didn't last more than a day or so before I found myself starting to recreate my "engine" stuff all over again. I mean, in the first few hours you need a camera, start building up gameplay and pretty soon you need physics/collision, start adding graphics and you need a way to manage draw order, get multiple objects using input and you need an input manager, you need a GUI system for menus, some kind of game-manager for pausing and reloading, etc., etc., etc....

It's not actually that much code, but perfecting it has been a perpetual process. I have a "scene-tree" like most game engines these days. That handles the basic callbacks and integrates with a draw-order manager. I use a few basic classes: "Object", "Sprite", "Camera", "PhysicsBody", etc. that I inherit to make custom behavior. I also have a very basic "script component" thing as an alternative way to add custom behavior to objects. An input manager, a physics helper, a basic asset loader, a UI behavior library, some sound stuff...that's about it.

Folder-wise it's usually:
assets/... --> tex/, font/, audio/
engine/
lib/
interface/
player/
enemies/
environment/
main.lua
conf.lua
(I haven't done any very big projects, so this may not be great...)
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: How do you organize your projects?

Post by Jasoco »

I have a folder with all my projects. A folder with older projects I abandoned so I can still get their code if I need to. And a folder with demos and samples downloaded from the forum and other snippets of code. Those last two folders are a mess but Spotlight still lets me search. My main project folder is more organized. And each project I do has all its files organized too.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: How do you organize your projects?

Post by Gunroar:Cannon() »

Jasoco wrote: Tue Jan 25, 2022 3:51 pm I have a folder with all my projects. A folder with older projects I abandoned so I can still get their code if I need to. And a folder with demos and samples downloaded from the forum and other snippets of code.
Hah!! Me too. I have all libraries I think might be useful, in their fresh zipped state, in a folder called .trashboat...just randomly named. Then I put all projects in a folder I am yet to rename out of laziness called likolove.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 21 guests