ID:121078
 
I blogged about this a while back but now it's really annoying. Most of my games turn out very similar, so there is no reason I should be starting a new DM environment every single time I make a game when about 80% of the programming will be similar. So instead of making a game that I'll probably just abandon for a new idea, I'm going to make things easy for myself and make a modular environment. That way when I get an idea I can immediately begin making the game instead of going through the same routine of programming things I've already programmed several times before.

I have a general idea of how I need to do this but I'm by no means a programming expert so I thought I would ask for some tips. What kind of advice can you guys give me on making something modular? This might even interest Forum_ account, I see he has been busy with tips and whatnot.
Little advice here to other Byonders. This is the 3rd time I've heard someone say that they ended up re-programming a lot of the same stuff the same way and they've realized that.

So if your trying to make your own "original" code, it's probably been done by someone else who has possibly done it better. You notice that when you work on something for a long time and notice it looks a lot like code you've already seen done previously by someone, or like a demo/lib that you just stumbled upon done better by someone else.

When I recently started trying to learn how to code, someone told me if my code looks a lot like the library/demo that I was learning from then I was pretty much ripping, but that's how I learned to do it, that's like you learned Karate then your martial arts teacher tells you to fight him using Kung Fu. (Which you know nothing about except from the movie 'Kung Fu Panda', but you never learned to master the finger move >.<.)
Truseeker wrote:
Little advice here to other Byonders. This is the 3rd time I've heard someone say that they ended up re-programming a lot of the same stuff the same way and they've realized that.

Yeah its not a good feeling. Everytime I start a new project, its "I have to program health bars into the game...again" or "I should just reuse that AI programming from Gnomeheim". It frustrated me so much that I refuse to make anything else until I make something to save me from all that time wasted.
Basic tip: If you can't pull a piece of code out and let it function on its own, it is not modular. Note that it's probably not possible for an entire, complex game to be written modularly (some stuff has to be game-specific), but a fair portion can be.
I pretty much came to say what Fizzy said.
Lul.
Datums.

Datums everywhere!
Popisfizzy wrote:
Basic tip: If you can't pull a piece of code out and let it function on its own, it is not modular. Note that it's probably not possible for an entire, complex game to be written modularly (some stuff has to be game-specific), but a fair portion can be.

Yeah. Planning to make one with things like DeathChecks, HUDs and loads of RPG-related variables already written in it.
This might not sound like much of a tip, but try writing code so that you can disable a feature by just un-including the code files that contain the feature. This isn't always possible - there are bound to be some additional lines you may need to comment out. But, generally, the easier it is to remove something from your game the more modular it is.

If your interface code is intertwined with your combat code, you can't remove one without removing the other. This also means that you can't take just one part and move it to another project. It also means that you can't easily revamp the combat system without also revamping the interface too.
I've practically given up on making projects as a whole, instead I have a 'handyStuff.dme' environment, cluttered up with small features that, if I ever do come to making a game again, I just need to pull a few code files from that and the engine's already done.
El Wookie wrote:
I've practically given up on making projects as a whole, instead I have a 'handyStuff.dme' environment, cluttered up with small features that, if I ever do come to making a game again, I just need to pull a few code files from that and the engine's already done.

I tried that, but I found it was easier just to split things into separate libraries and include libraries in other projects as needed. If you copy and paste code files into a new project, you can changes them to fit the project you're adding them to. If you keep things modular you can have a single library that's used by each project. While fixing bugs and updating libraries I used to have separate versions of the Sidescroller library that different projects used, but it was better to just fix all issues in the library and make it flexible enough that all projects used the same instance of the library.