Page 1 of 1

My Znax game working on raspberry pi

Posted: Fri Feb 14, 2020 12:29 am
by joyrider3774
Hello,

I converted an old game i created as a teenager from SDL1 to SDL2 and made it so it works on the raspberry pi in raspbian. My code will probably be bad as i'm no c/c++ developper in normal work life but actually a windows delphi developper so all of these things were very new to me and a lot of mistakes, codewise, may have been made.

The game is a simple arcade / puzzler. The aim is to get 4 blocks of the same kind form a rectangle. Blocks that form the rectangle wil be removed and new blocks will come in place. You'll get higher scores the more blocks you remove. The game also has 2 game options, relative timer and fixed timer. With the 1st option you start at a 3:20 timeframe and time goes down but you can gain extra time by creating rectangles. With the last option you get a fixed amount of time 10 minutes and need to get a score as high as you can. Highscores are saved although you can only enter highscores using the keyboard (arrow) controls, as the game was initially made for a handheld system. The game has skin support and i already created a few small skin deviations, one of them is a skin where the colored blocks are replaced by numbered blocks, and it makes the game a lot harder. You can however at any point change the skin using the L key on the keyboard.

The game also works with the official raspberry pi touchscreen although you may not introduce letterboxing due to resizeing (black borders) or the game won't detect your touch position correctly (i have not found a solution for this). It can also be played using keyboard and mouse

some screenshots:

Image Image Image Image Image

more details on the github page here https://github.com/joyrider3774/Znax

If you wish to try this out, open a terminal on raspbian desktop and type the following.

Code: Select all

sudo apt-get update
sudo apt-get install build-essential libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libsdl2-gfx-dev libx11-dev
git clone https://github.com/joyrider3774/Znax.git
cd Znax
make
sudo make install
if all went well the game should be installed in /usr/games/znax and a desktop entry under the games section should have been created in raspbian to launch the game. If it has not you can still launch the game using the following command after it has been installed

Code: Select all

/usr/games/znax/znax
to uinstall (when in the source directory Znax) use

Code: Select all

sudo make uninstall
it will remove the games folder and the desktop shortcut.

The game can also be build (using mingw32) and played on windows but i have not released a release yet with the binaries on github. The orginal sdl1 version with less options and skins is still available on my website

Re: My Znax game working on raspberry pi

Posted: Fri Feb 14, 2020 7:59 pm
by joyrider3774
touch screen problems with letterboxing are fixed. I just tried it on the official raspberry pi touchscreen. When the game starts and starting from the Main menu or anywhere else in the game press the F key to toggle fullscreen then everything is visible and you can use the touchscreen to play :) You could also use the -r commandline parameter to play immediatly in full screen mode

I also noticed on raspbian buster the game runs slow on a raspberry pi 2 but running in software mode gives more FPS and does not make it run sluggish (this does not apply to rapsberry pi 4 there hardware mode is faster). Not sure what's causing this though. You can run in software using -s commandline switch. if the game failes to create the renderer its probably because it can't adhere to vsync so run in software without vsync then with -s -d switches. You can view fps when in game mode using the -f switch. I kinda use my little game to benchmark all my pi perfomances :)

I also noticed disabling xcompmgr using raspi-config can give more fps