rapiz1 / DungeonRush

πŸ‘ΎπŸ A opensource game inspired by Snake, written in pure C with SDL
GNU General Public License v3.0
2k stars 294 forks source link

Make an AppImage #10

Closed probonopd closed 4 years ago

probonopd commented 4 years ago

Hi @Rapiz1. Would you like me to send a pull request that would make an AppImage?

Reference: https://discourse.appimage.org/t/how-to-add-a-system-envrionment-variable-in-an-appimage/1692

rapiz1 commented 4 years ago

Thanks for your interest! That sounds great.

probonopd commented 4 years ago

Mostly copy&paste from https://github.com/probonopd/linuxdeployqt#using-linuxdeployqt-with-travis-ci. Pull request coming.

probonopd commented 4 years ago

It's almost done but I am getting

me@host:~$ Downloads/DungeonRush-3390567-x86_64.AppImage 
Effect #0: Death loaded
Effect #1: Blink (white) loaded
Effect #2: Vanish (30fm) loaded
Unable to load image res/drawable/0x72_DungeonTilesetII_v1_3.png! SDL_image Error: Couldn't open res/drawable/0x72_DungeonTilesetII_v1_3.png
Segmentation fault

The game is currently loading res/ from the current directory the user is in, rather from the directory in which the game main binary is located. Can you change that? E.g., compute the location of res/ based on /proc/self/exe.

Something like this: https://github.com/aardappel/treesheets/commit/d0b4b60c270f73397ddf75ccb7759ec8d6b94765

rapiz1 commented 4 years ago

Loading from the directory of binary makes sense to me. However, /proc/self/exe is not portable and I'm still looking for a way to do that.

rapiz1 commented 4 years ago

I think there's no cross-platform trivial way to get the directory of current executable. The only way seems feasible is to #define and #ifdef around to make the program portable. ref: Finding current executable's path without /proc/self/exe

I don't know about how appimage works. Is it possible to make the entry point a shell script and then cd /path/to/bin && ./exe ?

rapiz1 commented 4 years ago

Also note that the binary has been renamed in https://github.com/Rapiz1/DungeonRush/pull/12

probonopd commented 4 years ago

Is it possible to make the entry point a shell script and then cd /path/to/bin && ./exe?

Yes, but it's a workaround:

https://github.com/AppImage/AppImageKit/blob/df8b13c19e569a6db0b9d186c81dd1ae4afbf58a/src/AppRun.c#L159