How to achieve organized and clean code and setup for a large game?

Hey, so I am working on an anime game that has dozens and dozens of abilities, along with different mode awakenings, and multiple combat systems such as fists, swords, bows, etc.

The point is that there is a mass amount of VFX and particles for these abilities, and a lot of code for the abilities, along with coding the combat systems.

My code right now works, but it is not organized and not friendly for future additions. Right now, I have a planned total of 40 abilities, and about 11 done. Along with this, Fist and Sword Combat is done, along with the stun and block system.

However, it is very tedious to add another ability, when I want it to be a system to easily add more abilities with their own damage, effects, etc.

Along with this, Fist and Sword Combat are all over the place, with tons of un-needed module requires that I don’t even use, functions there that I don’t even use, un-necessary code such as task.spawn when I could easily use task.delay.

I am asking you guys for a way to approach this in an organized, and optimized fashion, as I really do not want to spend a day on just one ability that isn’t even much crazy at all.

Please let me know!

2 Likes

Id say just keep everything in folders as having a lot of scripts and stuff is unavoidable. Make sure you have a folder for parts created within a script. As for your code just make sure you plan it out so that it isnt thrown together, another thing to remember is that its code that you yourself need to understand as you will be the one using it in whatever layout you decide to do. This means using modules and functions for repeat proccess like cframe manipulation.

Ive got over 100 scripts doing various things in my testing place and just using folders and using modules with frequently used things in means everything is organised.

E.g for my scripts folder ive grouped scripts based on what functions they do and purposes. I also keep all the modules in one folder for easy access from other acripts that may require it.

Id also suggest if you are edditing a script or creating a new one you keep that in another folder too (copy a script if you are edditing in case it doesnt work out) and have a script remove the folder when its not running in studio to reduce clutter and prevent spoilers.

1 Like

Maybe try using a networking framework like Knit? I recently got into it and I would say that it really helped me organize my code and understand my game better. Took a few hours to learn but saved me at least a few hundred lines of code (which may not be much, but it is quite something), and I don’t have to worry about remote events or any of that. Everything is modular, loaded in, and synced.

3 Likes

Just spend a day by yourself reorganizing refactoring it no other way around it. Personally I rewrote by game twice now switching from AeroGameFramework to Knit to now my own custom ECS implementation which uses custom features built from Knit like Components.

For a personal preference I recommend ECS for modularizing a system and reusing code though it takes a lot of time to get used to it, but the best way to describe it is once you create the systems you can mix and match what an entity can do like Lego’s pretty easily and allow you to create cool stuff.

However I also recommend trying out Knit like @RecanValor suggested, it helps you a lot in organizing your game or learning how to. However I couldn’t stand having to look constantly look at the documentation especially having to handle both ECS and Knit together. Also for the remote events problem you don’t necessarily need Knit for that, I found you can just use EasyNetwork for that which I like the API better.

2 Likes

Thanks for all the ideas! I’ve looked at all the frameworks and posts you guys have linked, and the ideas you have mentioned. Tomorrow I will spend the day just getting everything fixed. I definitely will try using EasyNetwork, framework wise however, I do not know what I am gonna do. I know a lot of games don’t use any type of framework, just their own code, but I enjoy using frameworks for other things outside of ROBLOX, so I’ll give them all a try in a test game.

2 Likes

Here is one of the method I use to organise my scripts maybe it will be of use to you

6 Likes