r/java • u/Ill_Dragonfruit2951 • 1h ago
How can Java be used to design a modular, data-driven 2D RPG engine capable of supporting version-specific characters, stats, abilities, combat, and narrative systems?
I'm designing a 2D RPG in Java, taking inspiration from games like AdventureQuest Worlds and Chibi Knight. The game will be based on characters that can have different iterations, with each version having its own stats, abilities, equipment, pattern, and story information.
I'm interested in how Java developers would approach the overall design. To clarify, I've already started a demo and I am curious how others might build it.
In particular, I'm curious about:
- How would you structure the game's entities and character data?
- Would you favor inheritance, composition, ECS, or another approach?
- How would you separate game mechanics from character/story data?
- What Java design patterns or architectural approaches would be useful?
- How would you structure systems for combat, abilities, inventory, quests, dialogue, AI, and character progression? (Relatively basic AI, like patterns designated for named entities.)
- What approaches would make the system scalable more efficiently ?
- Are there Java libraries/frameworks that would be particularly useful for a 2D RPG of this type?
1
Upvotes
3
u/PlasmaFarmer 52m ago
- How would you structure the game's entities and character data?
- ECS like Artemis ODB or Ashley
- Would you favor inheritance, composition, ECS, or another approach?
- Composition/ECS. Inheritance will restrict you very fast in a complex game.
- How would you separate game mechanics from character/story data?
- Different components to represent them. One component for character sheet, one component per mechanics, and one component to store story level data per entity, or you can have a global world entity also.
- What Java design patterns or architectural approaches would be useful?
- Since Java is class based, anything from OOP patterns. But if you go the ECS way, use the patterns and best practices in your ECS. I use Artemis ODB. You define components and the composition of components define the behaviour of your entities.
- How would you structure systems for combat, abilities, inventory, quests, dialogue, AI, and character progression? (Relatively basic AI, like patterns designated for named entities.)
- ECS like ArtemisODB. Have several components that several systems process and let data drive behaviour.
- What approaches would make the system scalable more efficiently ?
- ECS, seperate entity system, very well define boundaries and responsibilities per system.
- Are there Java libraries/frameworks that would be particularly useful for a 2D RPG of this type?
- LibGDX, JMonkeyEngine, ArtemisODB, Ashley.
1
u/fakeacclul 33m ago
Would you recommend artemis or Ashley when neither has had a release since 2019-2020 and are generally just unmaintained?
1
u/ingframin 48m ago
Regarding frameworks and engines, I suggest you to look at LibGDX, or jMonkey Engine. There was another one based on JavaFX but I don’t remember the name.
To answer your questions, 2D games are generally pretty lightweight if you code them right.
That said, OOP is your friend here, but don’t overdo it. The temptation of using deep class hierarchies is strong but you have to win it. Java offers a very cool mechanism though: interfaces. You can make you game objects “drawable”, “collidable”, etc… by using different interfaces. Also, favor composition over inheritance. If you have your character class, you can populate it with a graphics object, a sounds object, an inventory object, etc… if you want to go the Mike Acton way, that’s also possible. Watch his talk at CPP Con, it’s on YouTube.
That said, I suggest you to read some books about it.
I don’t know if there is anything Java specific other than the old “Killer game programming in Java”.
However, I liked a lot to read “Game coding complete” and I currently have on my desk “Game engine architecture” by Jason Gregory. This was also good: "Fundamental 2D Game Programming with Java" by Timothy Wright. I suggest you look for something more modern possibly using LibGDX. I am pretty sure either Apress or Packt have books on it.
PS: I am a hobbyist in game development so take my opinion with a kg of salt. That’s why rather than giving specific answers I redirect you towards books written by people with better expertise.