diff --git a/.gitignore b/.gitignore index 7c0ff56..426959b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ *~ -/releases \ No newline at end of file +/releases +/appimage/love-prepared/ +/appimage/AppRun-x86_64 +/appimage/appimagetool-x86_64.AppImage diff --git a/appimage/build.sh b/appimage/build.sh new file mode 100755 index 0000000..4246329 --- /dev/null +++ b/appimage/build.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +set -eo >/dev/null + +CURRENT_APPIMAGEKIT_RELEASE=9 +ARCH="$(uname -m)" + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 " + exit 0 +fi + +VERSION="$1" +LOVEFILE="$2" + +LOVE_TAR_URL=https://bitbucket.org/rude/love/downloads/love-${VERSION}-${ARCH}.tar.gz +LOVE_TAR=${HOME}/.cache/love-release/love/love-${VERSION}-${ARCH}.tar.gz +if ! test -f ${LOVE_TAR}; then + curl -L -o "${LOVE_TAR}" "${LOVE_TAR_URL}" +fi + +download_if_needed() { + if ! test -f "$1"; then + if ! curl -L -o "$1" "https://github.com/AppImage/AppImageKit/releases/download/${CURRENT_APPIMAGEKIT_RELEASE}/$1"; then + echo "Failed to download appimagetool" + echo "Please supply it manually" + exit 1 + fi + chmod +x "$1" + fi +} + +main() { + download_if_needed appimagetool-${ARCH}.AppImage + download_if_needed AppRun-${ARCH} + + # Extract the tarball build into a folder + rm -rf love-prepared + mkdir love-prepared + tar xf ${LOVE_TAR} -C love-prepared --strip-components=1 + + cd love-prepared + + # Add our small wrapper script (yay, more wrappers), and AppRun + cp ../wrapper usr/bin/wrapper-love + cp ../AppRun-${ARCH} AppRun + + local desktopfile="love.desktop" + local icon="love" + local target="love-${VERSION}" + + if test -f ../../game.desktop.in; then + desktopfile="game.desktop" + cp ../../game.desktop.in . + fi + if test -f ../../game.svg; then + icon="game" + cp ../../game.svg . + fi + if test -f ${LOVEFILE}; then + target="game" + cat usr/bin/love ${LOVEFILE} > usr/bin/love-fused + mv usr/bin/love-fused usr/bin/love + chmod +x usr/bin/love + else + echo "Love file ${LOVEFILE} not found" + fi + + # Add our desktop file + sed -e 's/%BINARY%/wrapper-love/' -e "s/%ICON%/${icon}/" "${desktopfile}.in" > "$desktopfile" + rm "${desktopfile}.in" + + # Add a DirIcon + cp "${icon}.svg" .DirIcon + + # Clean up + if test -f ../../game.desktop.in; then + rm love.desktop.in + fi + if test -f ../../game.svg; then + rm love.svg + fi + + # Now build the final AppImage + cd .. + + # Work around missing FUSE/docker + ./appimagetool-${ARCH}.AppImage --appimage-extract + ./squashfs-root/AppRun love-prepared "${target}-${ARCH}.AppImage" +} + +main "$@" diff --git a/appimage/squashfs-root/.DirIcon b/appimage/squashfs-root/.DirIcon new file mode 120000 index 0000000..9bfef7f --- /dev/null +++ b/appimage/squashfs-root/.DirIcon @@ -0,0 +1 @@ +appimagetool.svg \ No newline at end of file diff --git a/appimage/squashfs-root/AppRun b/appimage/squashfs-root/AppRun new file mode 100755 index 0000000..eb9d90d --- /dev/null +++ b/appimage/squashfs-root/AppRun @@ -0,0 +1,11 @@ +#!/bin/sh +HERE="$(dirname "$(readlink -f "${0}")")" +export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/sbin/:"${HERE}"/usr/games/:"${HERE}"/bin/:"${HERE}"/sbin/:"${PATH}" +export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}" +export PYTHONPATH="${HERE}"/usr/share/pyshared/:"${PYTHONPATH}" +export XDG_DATA_DIRS="${HERE}"/usr/share/:"${XDG_DATA_DIRS}" +export PERLLIB="${HERE}"/usr/share/perl5/:"${HERE}"/usr/lib/perl5/:"${PERLLIB}" +export GSETTINGS_SCHEMA_DIR="${HERE}"/usr/share/glib-2.0/schemas/:"${GSETTINGS_SCHEMA_DIR}" +export QT_PLUGIN_PATH="${HERE}"/usr/lib/qt4/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt4/plugins/:"${HERE}"/usr/lib32/qt4/plugins/:"${HERE}"/usr/lib64/qt4/plugins/:"${HERE}"/usr/lib/qt5/plugins/:"${HERE}"/usr/lib/i386-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib/x86_64-linux-gnu/qt5/plugins/:"${HERE}"/usr/lib32/qt5/plugins/:"${HERE}"/usr/lib64/qt5/plugins/:"${QT_PLUGIN_PATH}" +EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1) +exec "${EXEC}" $@ diff --git a/appimage/squashfs-root/appimagetool.desktop b/appimage/squashfs-root/appimagetool.desktop new file mode 100644 index 0000000..86eabaf --- /dev/null +++ b/appimage/squashfs-root/appimagetool.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=appimagetool +Exec=appimagetool +Comment=Tool to generate AppImages from AppDirs +Icon=appimagetool +Categories=Development; +Terminal=true + diff --git a/appimage/squashfs-root/appimagetool.svg b/appimage/squashfs-root/appimagetool.svg new file mode 100644 index 0000000..83ac565 --- /dev/null +++ b/appimage/squashfs-root/appimagetool.svg @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/appimage/squashfs-root/usr/bin/appimagetool b/appimage/squashfs-root/usr/bin/appimagetool new file mode 100755 index 0000000..6fb6f50 Binary files /dev/null and b/appimage/squashfs-root/usr/bin/appimagetool differ diff --git a/appimage/squashfs-root/usr/bin/mksquashfs b/appimage/squashfs-root/usr/bin/mksquashfs new file mode 100755 index 0000000..ac29f05 Binary files /dev/null and b/appimage/squashfs-root/usr/bin/mksquashfs differ diff --git a/appimage/squashfs-root/usr/bin/zsyncmake b/appimage/squashfs-root/usr/bin/zsyncmake new file mode 100755 index 0000000..4d85848 Binary files /dev/null and b/appimage/squashfs-root/usr/bin/zsyncmake differ diff --git a/appimage/wrapper b/appimage/wrapper new file mode 100755 index 0000000..2a634c1 --- /dev/null +++ b/appimage/wrapper @@ -0,0 +1,4 @@ +#!/bin/sh + +# For some reason this runs from the usr subdirectory +exec ../love "$@" diff --git a/lib/intersect.lua b/lib/intersect.lua deleted file mode 100644 index 10ad856..0000000 --- a/lib/intersect.lua +++ /dev/null @@ -1,15 +0,0 @@ --- https://love2d.org/wiki/General_math -return function(l1p1x,l1p1y, l1p2x,l1p2y, l2p1x,l2p1y, l2p2x,l2p2y) - local a1,b1,a2,b2 = l1p2y-l1p1y, l1p1x-l1p2x, l2p2y-l2p1y, l2p1x-l2p2x - local c1,c2 = a1*l1p1x+b1*l1p1y, a2*l2p1x+b2*l2p1y - local det,x,y = a1*b2 - a2*b1 - if det==0 then return false, "The lines are parallel." end - x,y = (b2*c1-b1*c2)/det, (a1*c2-a2*c1)/det - if not (math.min(l1p1x,l1p2x) <= x and x <= math.max(l1p1x,l1p2x) and - math.min(l1p1y,l1p2y) <= y and y <= math.max(l1p1y,l1p2y)) or - not (math.min(l2p1x,l2p2x) <= x and x <= math.max(l2p1x,l2p2x) and - math.min(l2p1y,l2p2y) <= y and y <= math.max(l2p1y,l2p2y)) then - return false, "The lines don't intersect." - end - return x,y -end diff --git a/love-release.sh b/love-release.sh index e5b89c4..f9920a5 100644 --- a/love-release.sh +++ b/love-release.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # LÖVE version -LOVE_DEF_VERSION=0.11.1 +LOVE_DEF_VERSION=0.11.2 diff --git a/makefile b/makefile index f2395c2..b9ba177 100644 --- a/makefile +++ b/makefile @@ -1,12 +1,22 @@ VERSION=0.1.0 -NAME=min-love2d-fennel +NAME=change-me URL=https://gitlab.com/alexjgriffith/min-love2d-fennel AUTHOR="Alexander Griffith" DESCRIPTION="Minimal setup for trying out Phil Hagelberg's fennel/love game design process." LIBS := $(wildcard lib/*) +LUA := $(wildcard *.lua) +SRC := $(wildcard *.fnl) +OUT := $(patsubst %.fnl,%.lua,$(SRC)) -$(LOVEFILE): $(LUA) $(OUT) $(LIBS) assets text +LOVEFILE=releases/$(NAME)-$(VERSION).love + +run: ; love $(PWD) + +%.lua: %.fnl ; lua lib/fennel --compile --correlate $< > $@ +clean: ; rm -rf $(OUT) + +$(LOVEFILE): $(LUA) $(OUT) $(LIBS) assets mkdir -p releases/ find $^ -type f | LC_ALL=C sort | env TZ=UTC zip -r -q -9 -X $@ -@ @@ -16,24 +26,27 @@ love: $(LOVEFILE) REL="$(PWD)/love-release.sh" # https://p.hagelb.org/love-release.sh FLAGS=-a "$(AUTHOR)" --description $(DESCRIPTION) \ - --love 11.1 --url $(URL) --version $(VERSION) --lovefile $(LOVEFILE) + --love 11.2 --url $(URL) --version $(VERSION) --lovefile $(LOVEFILE) releases/$(NAME)-$(VERSION)-x86_64.AppImage: $(LOVEFILE) - cd appimage && ./build.sh 11.1 $(PWD)/$(LOVEFILE) + cd appimage && ./build.sh 11.2 $(PWD)/$(LOVEFILE) mv appimage/game-x86_64.AppImage $@ releases/$(NAME)-$(VERSION)-macos.zip: $(LOVEFILE) $(REL) $(FLAGS) -M - mv releases/EXO_encounter-667-macos.zip $@ + mv releases/$(NAME)-macos.zip $@ releases/$(NAME)-$(VERSION)-win.zip: $(LOVEFILE) $(REL) $(FLAGS) -W32 - mv releases/EXO_encounter-667-win32.zip $@ + mv releases/$(NAME)-win32.zip $@ linux: releases/$(NAME)-$(VERSION)-x86_64.AppImage mac: releases/$(NAME)-$(VERSION)-macos.zip windows: releases/$(NAME)-$(VERSION)-win.zip +# If you release on itch.io, you should install butler: +# https://itch.io/docs/butler/installing.html + uploadlinux: releases/$(NAME)-$(VERSION)-x86_64.AppImage butler push $^ technomancy/exo-encounter-667:linux uploadmac: releases/$(NAME)-$(VERSION)-macos.zip diff --git a/mode-intro.fnl b/mode-intro.fnl index 379058b..42135b8 100644 --- a/mode-intro.fnl +++ b/mode-intro.fnl @@ -2,7 +2,8 @@ (var time 0) {:draw (fn draw [message] - (love.graphics.print "This window should close in 3s") 32 16) + (love.graphics.print (: "This window should close in %0.2f seconds" + :format (- 3 time))) 32 16) :update (fn update [dt set-mode] (if (< counter 65535) (set counter (+ counter 1)) diff --git a/wrap.fnl b/wrap.fnl index 721ca3b..791e0a5 100644 --- a/wrap.fnl +++ b/wrap.fnl @@ -1,5 +1,6 @@ (local repl (require "lib.stdio")) -(local canvas (love.graphics.newCanvas 720 450)) +(local canvas (let [(w h) (love.window.getMode)] + (love.graphics.newCanvas w h))) (var scale 1) @@ -12,10 +13,12 @@ (mode.activate ...))) (fn love.load [] - (: canvas :setFilter "nearest" "nearest") + (: canvas :setFilter "nearest" "nearest") (repl.start)) (fn love.draw [] + ;; the canvas allows you to get sharp pixel-art style scaling; if you + ;; don't want that, just skip that and call mode.draw directly. (love.graphics.setCanvas canvas) (love.graphics.clear) (love.graphics.setColor 1 1 1) @@ -25,14 +28,11 @@ (love.graphics.draw canvas 0 0 0 scale scale)) (fn love.update[dt] - (mode.update dt set-mode) - ) + (mode.update dt set-mode)) (fn love.keypressed [key] (if (and (love.keyboard.isDown "lctrl" "rctrl" "capslock") (= key "q")) (love.event.quit) ;; add what each keypress should do in each mode - (mode.keypressed key set-mode) - )) - + (mode.keypressed key set-mode)))