#!/bin/bash
INSTALLDIR="$HOME/.lbz"


if [ ! -d "$INSTALLDIR" ]; then
	mkdir $INSTALLDIR
	cd $INSTALLDIR
	echo "Downloading LemmingBallZ"
	curl -o installer.zip https://www.lemmingballz.eu/autoupdate/files/LemmingBallZALPHA_WIN_AND_LINUX.zip 
	echo Unzipping:
	unzip installer.zip > /dev/null
	mv LemmingBallZALPHA/* .
	echo getting linux binaries:
	tar zxvf linuxbinaries.tgz
fi

echo Running the game: stand by:
cd "$INSTALLDIR"

MISSING=`ldd LemmingBallZ | grep "not found"`
if [ ! "$MISSING" == "" ]; then 
	echo LemmingBallZ is missing the following 32Bit libraries on your system: 
	echo $MISSING
	echo
	echo Install 32bit libraries for SDL2 and OpenGL otherwise the game will not start.
	echo
fi
./LemmingBallZ $@ || echo "An error occurred, contact Menne Kamminga https://www.lemmingballz.eu"
