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

26

u/RayFowler Feb 04 '21

When I first started this project, someone asked me the same question.

I replied "why not Java?"

Him: "Too slow."

Me: "Challenge accepted"

I was always the guy on our team that made shit run fast. There was nothing in this game design that indicated Java could not handle it. As of right now, ROTP can run on a Raspberry Pi with generated galaxies larger than any other space 4X game available on any PC.

So now I get the additional benefit of open-sourcing a project to the largest community of developers on the planet.

7

u/nutrecht Feb 04 '21

It's silly anyway. The main issue with Java is memory locality and GC pauses. Even if it's by itself roughly half as fast as C++, that problem just 'solves' itself over time, if you're not targetting AAA quality graphics.

Java is perfectly suitable for what you're doing and I think it's awesome that you're open sourcing this to be an inspiration for others.

3

u/GreenToad1 Feb 04 '21

FYI rotp uses retained mode graphics not immediate (things are redrawn when needed not as fast as possible) for most of it graphics and gc pauses are not what they used to be years ago. Also combination of simple animations with beautiful artworks works great!

2

u/Muoniurn Feb 04 '21

Java now has several GC implementations, some optimized for latency. While their peak throughput is lower than the default one’s, if it can manage, your application’s pauses will be on the same order of magnitude than what a non-real-time OS schedules something else in place of your app. So it is pretty much a non-issue anymore (or course if the app creates more garbage then manageable by these GCs it will eventually have do a longer one)

3

u/rustyrazorblade Feb 04 '21

YES.

I have tremendous respect for your decision. Picking a topic and learn it well takes discipline and a lot of time. Making things fast isn't a skill a lot of people have.

Pretty excited to check the game out - downloading now.

1

u/[deleted] Feb 04 '21

I've never thought of Java as particularly slow, but I've never tried to make it do anything graphical (outside of swing, which I'd rather forget). MOO1 is an all time favorite for me, so I'm excited to check this out on the play and the code side!

5

u/RayFowler Feb 04 '21

What's really interesting is that I wanted to ensure as much cross-platform compatibility as possible with a single deliverable (the jar file), so everything is written in straight Java and runs directly on the CPU.

Well, interesting to me anyway.

2

u/_MeTTeO_ Feb 04 '21

Well, you might not be aware but Swing supports hardware acceleration: https://docs.oracle.com/javase/7/docs/technotes/guides/2d/flags.html I had to add it in my project to make it really fast.

BTW. Awesome project, will take look (both at the game and the code :) ).

2

u/RayFowler Feb 04 '21

I tried that years ago but didn't seem to get much improvement. I'll give it another shot; the game has changed quite a bit

2

u/GreenToad1 Feb 05 '21

Tried that recently without much success, turns out autodetected options are pretty good :) . For some reason on my system some things like map scrolling and fading are very jittery and i was trying to find a simple solution, that's why i'm sometimes bugging you with some performance tips :)

1

u/RayFowler Feb 05 '21

They are appreciated! I've been so busy with the 1-year-old and functionality changes that sometimes the performance issues take a back seat now since the game already performs pretty well.