Code organization

Status
Not open for further replies.

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
Yo!


First, I'm not sure if this is the correct place to post this.


I've been working on a few scripts for a roguelike, and until now I organized my code by plugin functionality. This is the same way we usualy do when using third party plugins for specific purposes, like:

  • Lets say I want a mini map on the map scene, I'll add a plugin for that.
  • Then I want to have fog of war on my map, I'll add a fog of war plugin.
  • Then I want random map generation and will add a plugin for that aswell.
  • And in the end, I want a HUD to be shown on the map scene... yes, another plugin



Note that all the plugins are related to the map, and they probably overrides a few functions that are common for each other. And also, the HUD plugin is related to the mini map plugin.


In this particular case, I'm woking on all the plugins myself and so I thought that I'm probably able to put it all together in an organized way so that all the engine works together as a whole.


But the thing is RPG Maker has already its design pattern to be easy to import plugins, and with that in mind I want to ask you: how do you think that would be a good way to organize your code when working with lots of related modifications? How do you do that if you do?
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
794
First Language
English
Primarily Uses
RMMV
I think you're doing it the right way @Lantiz; the organization of each feature should be a plugin of it's own design. 
You could possibly lump them all into one giant plugin, but if they're seperate, a person can use each feature on it's own if you ever decided to share em. 


Also, it's a lot less reading with multiple than going through one single source file with lots of different working parts. Long story short, you're on the right track.
 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
Oh I see your point.


Actually I din't mean to make it one file only, I meant to organize the project as a whole but not limiting to one file. It's just a way to put it tho.


Thanks for your words, sometimes I feel like using a bunch of plugins is kind of messy. Just me?
 

Kino

EIS Game Dev
Veteran
Joined
Nov 27, 2015
Messages
556
Reaction score
794
First Language
English
Primarily Uses
RMMV
Nah it can be, when you have a lot in one game, looking at the PluginManager can be scary. Lol
 

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
Here is what I do for plugin manager organization :





Sometimes I want to make a modification to an object, scene, or window but I do not want or need to create a full-fledged plugin. So I make miniature edits. Underneath the minor edits are the remainder of the plugins. I believe that creating one plugin per feature is best (although grouping similar features is also a good idea). I do not think that adding a bunch of plugins in is messy as long as you have some semblance of organization.
 
Last edited by a moderator:

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
@Exhydra now that's exactly what I was looking for.


Sometimes a plugin file gets too big and I have to scroll it up and down to find something, and this can be a pain...


Looks like going back to the old RPGM style would fit nicelly (like the engine was organized in Ace I mean).
 
Last edited by a moderator:

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
Well for someone wondering... latelly I found out that the plugin approach is still better.


The reason is simple: you can disable features on the editor. This is really useful when you are trying to find the reason for a bug sometimes.
 

Anisoft

Great Desu King
Veteran
Joined
Jun 17, 2015
Messages
97
Reaction score
83
First Language
English
Primarily Uses
Well for someone wondering... latelly I found out that the plugin approach is still better.


The reason is simple: you can disable features on the editor. This is really useful when you are trying to find the reason for a bug sometimes.


Exactly right, it's also always nice to have things organized in modular groups. 


 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
Yep.


Still bothers me to override the same classes in different files tho.


Also overriding the same function many times.


Anyway, looks like you got some neat plugins there.
 

Anisoft

Great Desu King
Veteran
Joined
Jun 17, 2015
Messages
97
Reaction score
83
First Language
English
Primarily Uses
Yep.


Still bothers me to override the same classes in different files tho.


Also overriding the same function many times.


Anyway, looks like you got some neat plugins there.


Ya well overriding functions is weird but it does allow for some easy overrides or inheritance. 


Also thanks, I'm glad you think they look cool. 
 
 

Abrasive

Warper
Member
Joined
Nov 2, 2016
Messages
2
Reaction score
1
First Language
English
Primarily Uses
It sounds like you want to do inheritance.  I'm brand new to RPG Maker so I'm not sure if the way the javascript files are set up that it would prevent you from doing that?  Javascript is pretty flexible so it seems like you could refactor the files in a way that they could inherit from a base map object and thus would have access to the common functions you mentioned.
 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
@Abrasive


Hi! Welcome!


It's not about inheritance, actually. RM makes good use of inheritance already, and so we do use it a lot.


The "problem" here (which is not a problem) is about the fact that it loads plugins by files so the developer can turn on/off the features of a given plugin anytime he want.


And by "problem" I mean it's when we are working on many aspects of the engine, making changes is many parts. By doing that we end up with code from the same class in different files, and overriding the same functions in many places.


Talking about organization, I find it to be troublesome, but in the end, being able to turn on/off plugins comes in hand when debugging.


Maybe we just need another way to handle the enabling/disabling. Or not at all...
 
Last edited by a moderator:

Abrasive

Warper
Member
Joined
Nov 2, 2016
Messages
2
Reaction score
1
First Language
English
Primarily Uses
@Lantiz
Thank you for the welcome :)


Now that you have elaborated some more it possibly sounds like a separation of concerns problem where things end up being tied to too many places.  Once I get rolling with RPG development I'm sure to run into the same issues.


To me, this is a red flag that I need to organize things differently, especially the latter portion of the sentence:

By doing that we end up with code from the same class in different files, and overriding the same functions in many places.


Sometimes callbacks can mitigate this so instead of overriding the same functions you tell the code to call back to a single place for the function.  Every project is different though, which is why architecture is a difficult problem to come up with solutions everyone can use.
 

Lantiz

PunyMagus
Veteran
Joined
Dec 29, 2012
Messages
723
Reaction score
1,074
First Language
Portuguese
Primarily Uses
Other
@Abrasive


Yeah.


They did an awesome job tho.


RPG Maker has "it's own way" of doing that, and it was translated nicelly so the people can be confortable with updates... it's comming from ruby (RGSS) to Javascript.


Also end users who does not code can keep using the engine the way they learned back when they started using scripts in their games.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top