RPG game architecture

before that I was doing regular games with 2-3 classes inside
now i want to make an rpg with features:

  1. cloathing (gui and geometry)
  2. skills (tree and skill bar)
  3. monsters
  4. inventory and drop items (gui)
  5. game levele with monsters
  6. sounds
  7. game save
  8. etc
    and the question arose how to distribute it by class

until I came up with the idea that the logic of the monster will be in custom control
level logic in app state
gui logic in each in their class
is it possible to create additional classes in threads inside the app state for logic with update methods

how would you do it?

can i do keypress handling in simple java class?

If you want to have an RPG with more than a handful of objects in it then you should learn about “entity systems” (also “entity component systems”) and properly separate your game objects from your visual objects.

It’s a big topic, though. It’s pretty much the industry standard for RPGs and RTS games these days.

You should consider learning about them.

The popular ECS library in JME is “zay-es”: GitHub - jMonkeyEngine-Contributions/zay-es: Zay-ES is a Java-based high-performance entity-component-system.
…and it has some persistence built in and can already do networking and stuff.

You can get pretty far as you are but you will end up eventually fighting your own code all the time. Either way, I recommend keeping “game logic” out of the controls.


A very good and easy tutorial about entity system with jme3 with 6 parts

I want to bring another idea, that I current use. I have no compare and clue what is better, it is just to show another idea so you could think about. Maybe, you could also combine.

RPG is a wide term, it is like calling a game a “Sport” or a an “Action” game. It says nothing about the content. Nevertheless, the first I think when I hear “RPG” is an adventure game with round-based fights against monsters like Final Fantasy, Lufia, Touhou shoujo tale of beautiful memories, Grandia and the German “Vampire Dawn”.

To come to the point, when I think about game development, I think always how could the game data get created by an game editor, to allow even people without any programming experiences and the unwill to learn them creating there own Add-ons or even full games. Some games lives only from user-contributed content. For this, I try to give all that’s possible in configuration files and script events.

In my current project, I thought about the powerful console of The Elder Scroll and Fallout where you could change nearly all, so I got the idea to try to implement all game functions (except the cores that are in case of such a RPG the inventory and fights (would also be possible but really a very big job)) as simple commands that just have zero to infinity arguments and no return value. It is for sure not the most efficient but a very generic way. The script lines get just splitted at space, the command handler object (split[0]) is gotten from an Map and executed.

In such RPG games, the commands to control objects are usual very simple, like:

*) Move an object or the player animated over some distance in a direction, turn them etc.
*) Add or remove an item to inventory
*) Add or remove a character to party
*) Start a fight against a monster group
*) Show a text box/Any input
*) Modify carried gold
*) Modify a boolean or integer game variable
*) if to test these variables and other things like character level and carried gold
*) Modify characters stats like HP and MP
*) Change game scene, player translation and rotation (“Teleport”)
*) “Teach” or “Forget” a magic skill
*) Show a shop screen
*) Show a save dialog that saves all game variables, player location, states and so on a file.

…and so on.

About 20 Years ago, I and much other played around with the RPG Maker 2000 (RPG2k). This is a game editor to create a Super Family Computer-Like RPG. If you want to develop such a game, you could look about the RPG Maker to get inspiration. I have no glue about the actual versions, but you may find also the 2000 version which contains really any function you would need. Even it is only 2D, this should not make a big different for the game logic.

If you have such an concrete view to the expected content, the class design should be also more obviously.

1 Like

There is RPG maker clone made with scala which is jdk language and it is opensource maybe you can take hints from it

By the way, make sure to study MonkeyTrap and AsteroidPanic examples. They use ECS with Zay-ES.

als sim-eth-es example

1 Like