Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for computers running Linux #4

Open
yosoyducc opened this issue Jul 22, 2024 · 4 comments
Open

Support for computers running Linux #4

yosoyducc opened this issue Jul 22, 2024 · 4 comments
Labels
feature Requesting new feature good first issue Good for newcomers

Comments

@yosoyducc
Copy link

I can see in the README that there are plans to port the game to Linux. That's awesome! I'm opening this issue to highlight the things that need to be done to port the game.

Laser Fighter currently makes some system calls to the Windows API. The head culprit is ScreenSetup.py which manages screen initialization. This file imports win32api and win32con to achieve this. While this approach works on Windows, it means other operating systems cannot run this game natively. This is the main reason the game will not run outside of a Windows environment. A possible solution is to use a more OS-agnostic approach to these windowing functions, like getting the monitor dimensions. I'm not aware of anything of this nature for Python at the moment, I'd have to look more into this.

Another thing to notice is this game also imports the font "Courier" from the system, which is not commonly found on OSes other than Windows. This can result in fallback to some really awful-looking default system font. We can see this in effect when running the game in WINE on Linux, which does not have the Courier font installed by default. A solution is to just include the font file with the game, but it's possible that the Courier font has a proprietary license, causing trouble with redistribution.

Aside from these two points, there shouldn't be much else that needs to be changed to port the game. I'd be interested in opening a pull request to work on this.

@Christian2147 Christian2147 added good first issue Good for newcomers feature Requesting new feature labels Jul 23, 2024
@Christian2147
Copy link
Owner

Thanks for your feedback! Yes I do plan on making this game Linux compatible in the future. Before that can be done, however, I need to make some major changes to the code once again so that the game is not using the poorly optimized turtle library. I would have done that this summer, but felt that working on code organization was more important. Once this change is made, I can begin working towards Linux compatibility.

@yosoyducc
Copy link
Author

I'd like to follow up. @Christian2147 and I have done some work on getting this to run on Linux. I've managed to get it to run on my machine, but only when deviating from the instructions a bit. I'll outline this below.

As of this commit e328eac, Linux instructions for setting up the env are accurate and work. However, some instructions are unclear, particularly around removing win32 dependencies. It tells us to use xrandr instead. There's no way to import xrandr into python that I am aware of.

Here are the instructions for what I did:

source/setup/WindowSetup.py

  • Comment out the two win32* imports.
  • Line 53: replace the two passed parameters in window.setup() with 1920 for width and 1080 for height.
  • Lines 58 and 59: set current_screen_width to 1920 and current_screen_height to 1080 (same values as above)
  • Line 108: comment out tk_window.iconbitmap('icon/Icon.ico') (icon loading doesn't seem to work...)
  • Line 305-307: comment out the DISPLAY_DEVICE and SETTINGS variables and set REFRESH_RATE to 60

Note: The reason why we're assigning 1920x1080 to these is because in this version the game does not appear to scale well with any other resolution.

source/utils/PreventSleep.py

  • Lines 52 and 61: comment out the two ctypes.windll* calls in prevent_sleep() and allow_sleep()

source/textures/lasers/Player_laser.gif

  • Rename this file to Player_Laser.gif

source/textures/interface/Icons/

  • Rename this folder to all lowercase, icons

monitor properties

  • Set monitor to 1920x1080@60Hz.

From here, running python3 main.py from within the source/ directory launched the game just fine. On my system, it seems to use an entire CPU core at 100%, whereas the Windows build from releases when run under Wine does not.

@Christian2147
Copy link
Owner

@yosoyducc Thanks for the follow up! I have added most of these to the instructions page. The rest of these procedures I plan on implementing in the games code through a Hotfix update coming up later in the week! All of these commands not working have to do with improper naming or Linux incompatibility.

I am not sure why the scaling is working incorrectly. Try implementing the solution that I gave and see if it scales correctly when on fullscreen mode. Windowed mode scaling has not been implemented yet.

@Christian2147
Copy link
Owner

@yosoyducc I have just released a new update which addresses some of the requirements for porting the game to Linux. Linux compatibility is possible if you follow the instructions on the instructions page. In the future, I plan on making this a fully automated process. Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Requesting new feature good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants