XII. ADD SOME GAMES
Added a couple of terminal games that actually run better within the KOReader terminal.
See the end of this post for instructions:
https://www.mobileread.com/forums/sh...91&postcount=3
***
Adding a tangram puzzle game to our Alpine chroot:
Now that we have luakit browser, we can actually play online, e.g. at:
http://www.tangramonline.com/
(If you have configured noscript, you may need to toggle scripts ','-'t'-'s', followed by a refresh 'r'.)
But we can compile a native tangram app with a better user interface:
https://gtans.sourceforge.net/
Tangram :
The Tangram is a chinese puzzle. The object is to put seven geometric shapes together so as to form a given outline. All the pieces must be used and are laid next to one another. The pieces are five triangles, a square and a parallelogram:
From your Kobo chroot (or PC SSH connection), download, edit, and build the source package:
wget
http://download.sourceforge.net/gtans/gtans-1.2.tar.gz
# cp gtans-1.2.tar.gz /home/root/
# cd /home/root
# tar zxvf gtans-1.2.tar.gz
# cd gtans-1.2/
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/loop0 2.0G 1.0G 848.1M 56% /
# apk add gtk+2.0
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/loop0 2.0G 1.0G 843.6M 56% /
# apk add gtk+2.0-dev
# df -h
Filesystem Size Used Available Use% Mounted on
/dev/loop0 2.0G 1.1G 752.3M 61% /
# pkg-config gtk+-2.0 --cflags
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/webp -I/usr/include/cairo -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/blkid -I/usr/include/pixman-1 -I/usr/include/libmount -I/usr/include/fribidi -pthread -I/usr/include/libpng16
# pkg-config gtk+-2.0 --libs
-lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lharfbuzz -lfontconfig -lgdk_pixbuf-2.0 -lcairo -lfreetype -lglib-2.0 -lintl -lpango-1.0 -lgobject-2.0
EDIT the following lines in the makefile:
# vi makefile
Code:
###
CFLG = -O2 -Wall -DGTK_ENABLE_BROKEN
###
#CFLG += -DTGTXT
###
$(PROG): $(OBJ)
$(CC) $(OBJ) $(LDFLG) `pkg-config gtk+-2.0 --libs ` -o $(PROG)
###
# cd po; make
###
callbacks.o: callbacks.c callbacks.h
$(CC) $(CFLG) -c callbacks.c `pkg-config gtk+-2.0 --cflags `
interface.o: interface.c interface.h
$(CC) $(CFLG) -c interface.c `pkg-config gtk+-2.0 --cflags `
main.o: main.c main.h
$(CC) $(CFLG) -c main.c `pkg-config gtk+-2.0 --cflags `
support.o: support.c support.h
$(CC) $(CFLG) -c support.c `pkg-config gtk+-2.0 --cflags `
###
# cd po; make DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install
###
EDIT the following lines in interface.c:
# nano -l interface.c
Code:
29 /* GtkAccelGroup *mgame_menu_accels; */
33 /* GtkAccelGroup *mprefs_menu_accels; */
36 /* GtkAccelGroup *mtans_menu_accels; */
41 /* GtkAccelGroup *mhitan_menu_accels; */
46 /* GtkAccelGroup *mbg_menu_accels; */
58 /* GtkAccelGroup *imsize_menu_accels; */
63 /* GtkAccelGroup *maccuracy_menu_accels; */
70 /* GtkAccelGroup *rotstp_menu_accels; */
80 /* GtkAccelGroup *mmisc_menu_accels; */
139 /* mgame_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (mgame_menu)); */
163 /* mprefs_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (mprefs_menu)); */
179 /* mtans_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (mtans_menu)); */
211 /* mhitan_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (mhitan_menu)); */
243 /* mbg_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (mbg_menu)); */
333 /* imsize_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (imsize_menu)); */
365 /* maccuracy_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (maccuracy_menu)); */
# make clean
# make
# make install
Run the program:
# gtans
Note that the program crashes if we use the menu to configure the colors.
We can use the config file instead.
EDIT the following lines in .gtans/.gtansrc:
# vi /home/root/.gtans/.gtansrc
Code:
gTans v1.0 config file 1
ispx 0
pxcol 0 0 0
pxnam /usr/share/games/gtans/pixmaps/gtans_burtwood.xpm
ispx 0
pxcol 32896 32896 32896
pxnam /usr/share/games/gtans/pixmaps/gtans_brightburtwood.xpm
ispx 0
pxcol 65535 65535 65535
pxnam /usr/share/games/gtans/pixmaps/gtans_wood.xpm
Run the program again:
# gtans
Use the up/down arrow keys to change the figure in Figure text entry box.
Maximize the window, and have fun!
***
Rather than use the above kludge, we can use the updated debian source:
https://packages.debian.org/buster/gtans
Download the debian source and patch:
wget
http://deb.debian.org/debian/pool/ma....0.orig.tar.gz
wget
http://deb.debian.org/debian/pool/ma...99.0-2.diff.gz
On the desktop, apply the patch:
$ tar zxvf gtans_1.99.0.orig.tar.gz
$ gunzip gtans_1.99.0-2.diff.gz
$ mkdir gtans-1.99.0/debian
See what the "Makefile.in" file looks like before the patch:
$ nano -l gtans-1.99.0/data/Makefile.in
18 pkgdatadir = $(datadir)/@PACKAGE@
Apply the patch:
$ patch -p0 < gtans_1.99.0-2.diff
See what the "Makefile.in" file looks like after the patch:
$ nano -l gtans-1.99.0/data/Makefile.in
18 pkgdatadir = $(datadir)/games/@PACKAGE@
Bundle your newly patched source to gtans_1.99.0.tgz:
$ tar zcvf gtans_1.99.0.tgz gtans-1.99.0/
Copy gtans_1.99.0.tgz to your Kobo and build:
(Assuming you have done "apk add gtk+2.0-dev" and "make uninstall" from previous installation.)
# tar zxvf gtans_1.99.0.tgz
# cd gtans-1.99.0/
# ./configure
# make
# make install
# mv /usr/local/bin/gtans /usr/bin/
# gtans
(No more buggy menu behaviour.)
***
Debian changed their patch file system. For example:
https://packages.debian.org/bullseye/tuxpuck
Download the debian source and patch:
wget
http://deb.debian.org/debian/pool/ma....2.orig.tar.gz
wget
http://deb.debian.org/debian/pool/ma....debian.tar.xz
On the desktop, apply the patch:
$ tar zxvf tuxpuck_0.8.2.orig.tar.gz
$ cd tuxpuck-0.8.2/
Apply the patch (looks like we have to use a debian tool to patch this one because of the ".debian.tar.xz" format of the patch):
$ tar xvf ../tuxpuck_0.8.2-11.debian.tar.xz
$ dpkg-source -b .
(We will not be building tuxpuck due to other build issues.)
***
XBoard is a graphical user interface chess app:
https://www.gnu.org/software/xboard/
# apk add xboard
# xboard
EDIT the "Multimedia" section of /home/root/.config/openbox/menu.xml to add an xboard item:
Code:
<menu id="apps-multimedia-menu" label="Multimedia">
<item label="Xboard">
<action name="Execute">
<command>xboard</command>
<startupnotify>
<enabled>yes</enabled>
</startupnotify>
</action>
</item>
Propagate your changes to the /home/myuser/ account:
# cp -r /home/root/.config/ /home/myuser
# chown -R myuser:myuser /home/myuser/.config
***