Skip to main content

Games for sysadmins: Prince of Persia 1 on Linux with SDLPoP

SDLPoP is an open source port of a classic game from the 80s and 90s. Let the games begin!

 

SDLPoP is an open-source port of the classic 80s and 90s game Prince of Persia. It's based on the disassembly of the DOS version and documentation provided by the game creator Jordan Mechner. It's licensed under the GPL v3 license.

Image
sdlpop-intro-screen

This classic game features a 2D side scroller with 12 levels filled with puzzles and adventure that will test your logic and abilities. At the time of launch, the game was popular due to the beautiful level design, the fluidity of the character's movement, and the time component.

Image
sdlpop-level-design

One of the main innovations of the game was including a time component. You had 60 minutes to complete the game, or it was game over, regardless of the point you were in the game. After that, you had to start the game from the beginning again. This component added to the excitement and the difficulty as you not only had to figure out some of the puzzles and beat the levels, but also master them in a short time to complete the game.

Image
sdlpop-time

In addition to the classic experience, SDLPoP adds the ability to save and load the game progress, record gameplay, save screenshots, and play "mods" - modified versions of the game.

Let's start by installing SDLPoP on Fedora.

Installing on Fedora 32

SDLPoP is available in the package repository of some Linux distributions. However, on Fedora, to play the game, you need to compile it from the source code. Let's do that.

First, install the required dependencies, libraries, and compiling tools:

$ sudo dnf install -y git make gcc SDL2_image-devel.x86_64 SDL2.x86_64

Then, download the source code for the game from the Github project:

$ git clone https://github.com/NagyD/SDLPoP

Finally, switch to the src directory and compile it:

$ cd SDLPoP/src
$ make all

If you want to launch the game from the Applications menu, you can use make install:

$ sudo make install

The game is now installed. Let's look at an alternative way to compile it.

Installing the modern sysadmin way

Compiling and installing the game requires downloading and installing many dependencies and compiling tools on your Linux machine. If you don't want to do this, you can still compile the game using containers with Podman.

First, clone the source repository:

$ git clone https://github.com/NagyD/SDLPoP

Next, create a container image with the required tools and dependencies to compile the game. Create a subdirectory and a Dockerfile like this:

$ mkdir -p SDLPoP/podman
$ cd  SDLPoP/podman
$ vi Dockerfile
FROM fedora:32

RUN dnf update -y \
    && dnf install -y make gcc SDL2_image-devel.x86_64 \
    && dnf clean all \
    && rm -rf /tmp/* /var/tmp/*

VOLUME [ "/SDLPoP" ]

WORKDIR "/SDLPoP/src"

CMD [ "make", "all" ]

Then, save the file and use podman build to build the new image with the name sdlpop-build:latest:

$ podman build -t sdlpop-build:latest .

Verify that the image was built correctly with podman images:

$ podman images
REPOSITORY                                       TAG     IMAGE ID      CREATED         SIZE
localhost/sdlpop-build                           latest  e4f140a64079  49 seconds ago  494 MB

Now that you have the container image with the required dependencies, use it to compile the game.

$ cd .. 
$ ls
data  doc  mods  podman  README.md  SDLPoP.ini  src
$ podman run --rm -v .:/SDLPoP:Z localhost/sdlpop-build

The game is available in the source code directory as prince. You can run the game with ./prince. If you want to install the desktop file to launch the game from Applications menu, switch to the src directory and run the install.sh script with elevated privileges:

$ cd src
$ sudo ./install.sh

The game is ready to play.

Cheats

I remember that back in the early 90s, completing this game was a challenging but rewarding experience. Shortly after completing the game for the first time, I was amazed to learn that you can enable cheats. SDLPoP allows you to do the same. To enable cheats, launch the game with the megahit option:

$ ./prince megahit

With cheats enabled, you can use special keys to change the game flow. For example, use Shift+L to skip a level, + to increase your time, Shift+S to recover energy, and more. Look at the project page for a complete list.

What's next?

Now that you have SDLPoP installed, you can re-live this classic game if you're a veteran or enjoy an exciting adventure as a first-timer.

While you're at it, see if you can beat my time. But no cheats.

Image
sdlpop-high-score

[ Free download: Advanced Linux commands cheat sheet. ]

Topics:   Linux  
Author’s photo

Ricardo Gerardi

Ricardo Gerardi is Technical Community Advocate for Enable Sysadmin and Enable Architect. He was previously a senior consultant at Red Hat Canada, where he specialized in IT automation with Ansible and OpenShift.  More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.