flags / Reactor-3

Post-apocalyptic action roguelike with a focus on inventory management and gun-based combat.
MIT License
71 stars 11 forks source link

Port to Python 3. #132

Open HexDecimal opened 3 years ago

HexDecimal commented 3 years ago

I often hear about this game but I don't think there's been a binary release anywhere. I wanted to look at it but would rather not reinstall Python 2.7. I have experience with updating older Python code.

I've ported the sources to Python 3 and updated the code to use the newer versions of python-tcod. The current program seems to be full of regressions but I can't always tell if they are from porting the code or from the master branch itself compared to the latest tagged commit. There were some cases where I needed to fix issues unrelated to the port to get the game running.

Updates to libtcod mean an update to SDL2 so key repeat behavior is affected. This code uses a lot of division which has changed behavior in Python 3. I can't be sure that division is correct until type hinting is added.

This update allows distributing releases via PyInstaller. You no longer need to manually handle DLL files and can more easily run the game on Mac or Linux.

I'm under the impression that this project is abandoned. Are there any updates on that?

flags commented 3 years ago

This is really cool! A few people have taken a stab at this but ran into issues. I really appreciate the work. Once I get some time to dive into it I'll see what I can do to get it merged.

And yes, this version was abandoned right after the last commit (2014?) I made some minor fixes later on for whatever reason, probably to get it running for a demo. I did a rewrite in C a few years ago, but that was for a commercial release that had its production halted.

I'll get to this merge eventually, maybe within a week or so. Thanks again!

HexDecimal commented 3 years ago

I was hesitant to mark this as ready since it felt like there was probably more I could do. The key repeat changes affected movement but I'm not sure how I should adjust it. I might also add automated builds using GitHub Actions which is something I can do easily. There are also graphical issues with the UI where it looks like the UI background isn't being cleared.

A few people have taken a stab at this but ran into issues.

I've spent a lot of time writing code that supports both versions of Python 2/3 and helping others port code to Python 3.

I used the 2to3 tool. After that I ran into issues I recognized as Python's new division handling. You have to go though each use of division and decide if the result is supposed to be a float or integer. Most things related to chunk handling need floor division. Cases where you'd need to cast to float before division are now converted to float automatically.

I then had minor issues with importing. The star importing of the alife sub-modules causes issues with static analysis tools which affected PyInstaller. I had to hard-code these sub-modules into PyInstaller and add a note explaining that altering the sub-modules will break things. This would be fixed if those packages are imported by name anywhere.

HexDecimal commented 3 years ago

Here are some test builds I have so far. There's an Ubuntu build too, but it's slightly too big to attach.

windows-2019.zip macos-10.15.tar.gz