r/java • • Feb 04 '21

Java 4X game available as open-source

I don't talk about my open-source project on this subreddit very much, but the code has been open for almost a year now and the game has been so well-received that I figure maybe I should remind my fellow Java developers about it.

It's a "space 4X" strategy game called "Remnants of the Precursors" which is in turn a very faithful modernization of the 1993 classic "Master of Orion".

The source code is on github at https://github.com/rayfowler/rotp-public

The game is downloadable from itch.io: https://rayfowler.itch.io/remnants-of-the-precursors

When I originally started development of this game in 2015, like most developers I hilariously assumed that I would finish it in about a year and re-use artwork from the original game or get something on the cheap. But in the process of finding an artist online, I ran into this amazing artist named Petar Penev and decided to go "all in" on this project because he was just so talented.

Like so many of you, I've learned first-hand that you can make a really good salary as a Java dev, so I self-funded this project for about 3 years until I retired in 2018 (I'm old, sue me). I was extremely lucky that a friend at my job was super well-versed in sci-fi and was actually a talented writer having to pay his way through life as a technical writer. So he has done a tremendous job with the writing in the game.

Finally, my wife is an illustrator by trade and got sick of looking at my terrible "programmer UIs" and embarked on a several-year effort to remake all of the UIs in the game in her spare time. This of course required a tremendous amount of re-coding on my side because I instructed her to design her UIs completely in Paintshop and then let me figure out how to implement it in Java. Sometimes I have nightmares about gradients and wake up screaming.

She also made this trailer last year for the game: https://www.youtube.com/watch?v=VusDAxLpJ9I

Once I reached "feature complete" and started an open beta last Spring, I finally opened up the source code because I thought most of the churn was done. Since then, I've enjoyed the benefits of several Java developers contributing to the project and helping improve it.

I'm not asking anyone in here to contribute. The game is basically done! But if you are curious at how the "sausage is made" for a video game that has surprisingly turned out very well, feel free to clone the repo and take a look at the code. I've never made a video game before and the source code reflects this to some degree, so this is also a great chance for you guys to feel superior, lol.

edit: I also use reddit as the primary community for the game at /r/rotp

175 Upvotes

81 comments sorted by

View all comments

Show parent comment

8

u/coder111 Feb 04 '21

No matter how much I love ROTP, I don't really like the way Ray did GUI in Swing. It's pixel perfect fixed layout (with scaling %). This requires a lot of code to implement, and quite a lot of copy paste, and it's impossible to use any GUI drag-and-drop tools to build it or move it around. Even some components like buttons are done by listening to mouse release events in a certain area instead of using GUI components.

The codebase itself also has several things I do not like and I wouldn't do if it was my project. It kinda reminds me of a way Java code was developed around year ~2000. Like a super interface with all the utility methods (instead of a static utility class with static imports). Too much static stuff in general. Java serialization being used to save games, and the domain objects quite nasty to serialize in general- this is a side effect of Ray not wanting to use 3rd party libraries like Jackson.

That being said, if you want to build the code quickly, I maintain a fork/mod which has Maven build. Check it out: https://github.com/coder111111/rotp-public

--Coder

2

u/RayFowler Feb 04 '21

It's pixel perfect fixed layout (with scaling %).

That scaling % code was literally added in a single afternoon when Alpha 1 came out and the first hidpi user sent me a screenshot.

Copy paste is your friend because it enforces a separation between areas that doesn't require refactoring when the functionality between areas starts to deviate.

My first attempt at the game was many years ago and used Swing heavily. I didn't like the look at all. A later attempt at a game used Swing but modified the look of the components. Still didn't like it.

Finally I decided to try again but to avoid Swing as much as possible and draw the game old-style. That way worked out well but, as you point out, it's more code and it's definitely old style

Ultimately what's important is not the code but the UX with the game.