Tag Archives: free pascal

Android News Cover Image

About SDL2, Free Pascal and… Android

Since the rise of SmartPhones, many wonder if Free Pascal/SDL2 development  is possible for them, too. The good news is, yes it is possible! The bad news is, it is kind of toilsome to set up a development environment for Android (one of the two major operating systems of many SmartPhones).

Imants Gulbis informed me that he set up a Lazarus package (LazSDL2Design) which makes development of SDL2 applications with Free Pascal for Android fairly simple and integrates with the Lazarus IDE. Check out the instructions to make Lazarus/SDL2 ready for Android. The LazSDL2Design package relies on an own translation of SDL2 headers (LazSDL2) by him.

I put together some useful resources for Android development in the FAQ.

Thanks to reader Paul for letting me know about an unclear statement in Chapter 8 Part 1.

The website uses HTTPS now.

Android, SDL2 and Pascal?

Recently, I get more and more questions and requests regarding the development of Android applications with SDL2 and Free Pascal. Since I’m not planning to do a tutorial chapter on this in the near future, I would like to share some resources which may help you to set your system up. – Contact me, if you are interested in sharing a tutorial on how to set up a SDL2/Free Pascal/Android development environment (or if you know further resources which should be covered here).

  1. This step by step tutorial describes very detailed the setup of a SDL2/Android development environment under Window, though it aims for C++ development rather than Pascal development: 

http://lazyfoo.net/tutorials/SDL/52_hello_mobile/android_windows/index.php.

  1.  This is a short introduction how to setup your system and Lazarus (Free Pascal) to develop Android Apps:

http://wiki.lazarus.freepascal.org/Android_tutorial.

  1. These links lead you to a Lazarus package that allows for SDL2 and simple Android development and a configuration of it:

https://sourceforge.net/projects/lazsdl2.
https://sourceforge.net/p/lazsdl2/wiki/LazSDL2Design%20configuration.

 

 

 

Linux Tutorial News Cover Image

New Linux Installation Chapter

A new Chapter 2 has been added. In contrast to the classical Chapter 2 which explains the installation of SDL2 and Free Pascal for the Windows operating system, the new Chapter 2 explains the installation and configuration of SDL2 and Free Pascal/Lazarus in Linux. Initially I was trying to check for some troubles which got mentioned. Finally I ended up with a short, new installation chapter. A few minor changes have been added to the other chapters which are basically hints for Linux users.

A few new great and interesting Free Pascal/SDL projects have been added to the project page. These are namely GearHead: Arena, GearHead 2, Dungeon Monkey Unlimited, Monsterland and DoomRL. The former three are open source by the way.

DoomRL

Short description

DoomRL is based on ID’s famous Doom game. The RL means roguelike.

Showcase and Basic Data

Developer granted permission to use these screenshots.

  • Project name: DoomRL (a.k.a Doom, the Roguelike)
  • Author: Kornel Kisielewicz (Code/Design), Derek Yu (art)
  • Latest version: 0.9.9.7
  • Release date: 2001 (initial version), 19 March 2013 (latest version)
  • Pascal compiler: FPC 3.0
  • SDL Version: 1.2
  • Further libraries: Lua, OpenGL, FMOD
  • License: Donationware
  • Open source: no
  • Official website: http://doom.chaosforge.org

Interview with Kornel Kisielewicz

Why did you decide to choose Pascal as a programming language and SDL as a library for your projects?

Kornel Kisielewicz: Pascal was my first language, and in those days C++ was quite messy. I liked the clean syntax of Pascal and it’s default strong type system. SDL was a no brainer, we wanted a platform independent layer for OpenGL context creation and Input handling, and SDL was the only reasonable choice in that regard at the time.

What do you think is the most interesting Pascal/SDL/SDL2 project out there (besides your own, of course :-D)?

Kornel Kisielewicz: I have been out of touch with the Pascal scene for a long time now.

Are there any new projects planned?

Kornel Kisielewicz: We’re currently working on Jupiter Hell, a spiritual successor to DoomRL, but it’s in full 3d, and written in C++.

Chapter 2 – Installation and Configuration (Linux version)

This chapter illustrates quickly how to get an environment for Free Pascal/SDL2 development running under Linux. Attention: The following instruction may work for many Debian and Ubuntu based Linux distributions, others probably need different installation procedures.

In contrast to the Windows, in Linux there are so many variables according to the operation system (thousands of different distributions) that there can’t be a more or less generalized way how to install it. Anyway I’d like to demonstrate how it worked for me and give some hints which may help you to install it to your favorite distribution of Linux.

The distribution and software I used:

  • Linux Distribution: Linux Mint 17.2 (Ubuntu/Debian based)
  • Desktop: Cinnamon Desktop
  • Lazarus 1.6 (installed from .deb file)
  • FPC 3.0.0 (installed from .deb file)
  • FPC 3.0.0 Source Code (installed from .deb file)
  • Tim Blume’s SDL2 units (header translation)
  • SDL2, SDL2_image, SDL2_ttf dynamic library files (Linux has .so files instead of .dll files)

Download and install FPC, FPC sourc code and Lazarus

The first step is to install the Free Pascal compiler (version 3.0.0 or higher), the Compiler’s source code (same version as the compiler) and the Lazarurs IDE (version 1.6 or higher). First check if your package manager provides this software in these (or higher) versions! It is likely that you find the software but the versions may lack behind. If that is the case, download and execute these three .deb files in the shown sequence.

Again Careful: These files are right for many Debian and Ubuntu based distributions (like Linux Mint) but may be wrong for others. Try to find out the right ones for your Linux.

  • fpc_3.0.0-151205_amd64.deb
  • fpc-src_3.0.0-151205_amd64.deb
  • lazarus_1.6-0_amd64.deb
  • Download source: http://lazarus-ide.org (find the download button)
Install Packages for Linux FPC SDL2 environment with Lazarus
SourceForge download page for all three files necessary (accessed via Download button at lazarus-ide.org). The original description is kept in the image.

 

If everything went right, Lazarus can be started up by typing “startlazarus” in the terminal or by finding the program here: /usr/bin/startlazarus which is a symbolic link to the actual executable here: /usr/share/lazarus/1.6/startlazarus. On your system it may be located at a different location but these are rather standard location.

Start up Lazarus

On start up of Lazarus the directories for FPC and the FPC source code were found and set already. As a hint I show where these are located on my system are:

  • FPC: /usr/bin/fpc
  • FPC Source code: /usr/share/fpcsrc/3.0.0 (because $(FPCVER) equals the version number, see screenshot)
Path FPC and FPC Source code
Either detected automatically or can be manually added by Tools > Options …

Before proceeding, my suggestion is to start a new project (simple program) and try out if you are able to do a simple compilation of a very simple program. E.g. a simple writeln-statement.

As a tip you should open up Lazarus’ Console to see the output of your program and writeln commands. You can find the Console at Window > Console.

Get the SDL2 units

Get the latest version of the translated SDL2 units.

Download SDL2 units on GitHub
Choose the master branch (1), click on “Clone or download” (2) and click on Download ZIP (3).

Make sure you have the master branch chosen and then click on “Clone or download”, then “Download ZIP”.

After extracting the ZIP file I suggest to rename the new folder into “sdl2” or “SDL2” and place it at this location:

  • /usr/local/share/
  • SDL2 units are then here: /usr/local/share/sdl2
Path to SDL2 units
This folder is suggested as a place for the SDL2 units. By the way, “Chap7” is just a random name for this project and you may have anything else there instead (I was trying out Chapter 7 tutorial code).

To copy the folder to /usr/local/share/ you usually need root permission. Also make sure the new folder allows for access to its files. In my case I had to make sure that the “root group” has access to files.

Get the SDL2 dynamic library

If you are looking for the most recent pre-compiled SDL2 dynamic link library files (e.g. libSDL2.so) on the official SDL2 website, you just find a remark that reads like this:

Linux:
Please contact your distribution maintainer for updates.

Since SDL2 is very widespread it is very likely that you distribution maintainer already included the files.

Find SDL2 and all necessary libraries in your distribution’s package manager. Perhaps you have a search field as shown (upper right arrow). The screenshot shows what could come up then:

SDL2 in package manager
Installation of the SDL2 dynamic link libraries in Linux via the package manager.

As you can see, for me at this moment the SDL2 dynamic link library, version 2.0.0 (libsdl2-2.0.0) was already installed (the small green check mark indicates this in Linux Mint). Anyway, SDL2_gfx (libsdl2-gfx-1.0.0) and SDL2_image (libsdl2-image-2.0.0)  weren’t installed.

Find all necessary libraries and install them. These you should install:

  • SDL2
  • SDL2_image
  • SDL2_ttf
  • SDL2_mixer

At least for my tutorials SDL2_gfx is not necessary but you may try it out.

The version of these libraries does not necessarily need to be the most recent unfortunately. If you really need the most recent versions here, you may try to contact the maintainer to ask to update the version.

That’s it :-)!…. – Unfortunately I ran into troubles…

The linker doesn’t find libSDL2.so

So, what I got when I tried to run the basic SDL2 code from Chapter 3:

  • /usr/bin/ld: cannot find -lSDL2

Linker error message

Although I installed the SDL2 dynamic link library I get the linker saying it cannot find it. When looking for sdl2 in /usr/lib and its sub-folders where dynamic link libraries are placed usually, I got these two files:

  • libSDL2-2.0.so.0 (which is a symbolic link to the file below)
  • libSDL2-2.0.so.0.2.0 (this is the correct file!)

Anyway, the linker expects libSDL2.so, so what can you do? – Create a symbolic link with that name. This is done in the Terminal by:

Create a symbolic link to libSDL2.so

  • locate SDL2: shows where SDL2 is located and how it is named (for me they were in /usr/lib/x86_64-linux-gnu)
  • sudo ln -s [destination of symbolic link] [name of the symbolic link]
  • sudo requires to enter the root permission password

Repeat the same for all libraries (SDL2_image, … and so on) you want to use.

Congratulation! After that, everything should run smoothly :-)! I tried chapter 3-9 and all worked well for me.

Linux specific experiences

Launching application invalid

On opening up a Lazarus project (.lpi file) and try to re-run it, I get an error window titled “Launching application invalid” which said “The launching application “”[full path including the execution file of the project]”” does not exist or is not executable.” and further “See Run -> Run parameters -> Local“.

Not sure why this is. Anyway, deleting the executable from the project folder or compiling the project before running it, fixes this issue.

← Chapter 1 | Chapter 3 →

Monsterland

Short description

A commercial action shooter with appealing DOS-like appearance by developer Second Variety Games.

Showcase and Basic Data

Developer granted permission to use these screenshots.

  • Project name: Monsterland
  • Author: Second Variety Games
  • Latest version: 1.15
  • Release date: 12/14/2015
  • Pascal compiler: Free Pascal 3.0.0
  • SDL Version: 1.2
  • Further libraries: sdl_image, sdl_mixer
  • License: commercial product
  • Open source: no
  • Official website: none except Steam page: http://store.steampowered.com/app/406920

Interview with Aleksey from Second Variety Games

Could you please give a short description of Monsterland for those who have never heard of it?

Aleksey: Monsterland is a 2D realtime shooter portrayed entirely through ASCII characters. This includes blood, lighting, particles, etc. Its only gameplay mode is a 3-hour story campaign, which has voiceovers, triggers and scripted sequences. The gameplay of Monsterland was heavily influenced by original Doom games (1 and 2).

Why did you decide to choose Pascal as a programming language and SDL as a library for your projects?

Aleksey: Pascal is an underrated, well-rounded programming language. It has good diagnostics and strict syntax, which removes ambiguity from error messages. It also helps that I was first introduced to it in 1992.

SDL was chosen because I’ve also been writing an engine tied to DirectX, and given where Windows is heading, it was a mistake I didn’t want to repeat. SDL 1.2 didn’t have accelerated 2D though, so I had to do it via OpenGL manually.

What do you think is the most interesting Pascal/SDL/SDL2 project out there (besides your own, of course :-D)?

Aleksey: If Dwarf Fortress still used Pascal, I’d name that. Otherwise, DoomRL I guess.

Are there any further steps planned for the Monsterland series? What will they be?

Aleksey: Aw, you flatter, but Monsterland will not be continued.

Are there any new projects planned?

Aleksey: I’m starting to work on a new type of IF (interactive fiction) game. I clearly have an obsession with text visuals.

There’s also the ambitious isometric RPG I’ve been writing in C for years, the “magnum opus”, but it’s too ambitious at the moment, even though a lot of work has been done. I wish I wrote it in Pascal instead – it would’ve been easier to debug.

 

Dungeon Monkey Unlimited

Short description

Dungeon Monkey Unlimited is a turn-based, rouge-like role-playing game where you can explore ancient worlds with benign graphics.

Showcase and Basic Data

Developer granted permission to use these screenshots.

  • Project name: Dungeon Monkey Unlimited
  • Author: Joseph Hewitt; graphics obtained from the David Gervais and rltiles sets.
  • Latest version: 1.001
  • Release date: September 20 2010.
  • Pascal compiler: Free Pascal
  • SDL Version: 1.2
  • Further libraries: Only those that come with the FPC compiler
  • License: GPL
  • Open source: Yes
  • Official website: www.gearheadrpg.com

GearHead 2

Short description

GearHead 2, successor of GearHead: Arena, is a turn-based, rouge-like role-playing game where you can explore futuristic worlds with benign graphics.

Showcase and Basic Data

(no showcase screenshots provided)

  • Project name: GearHead 2
  • Author: Joseph Hewitt, plus the work of several contributors
  • Latest version: 0.628
  • Release date: The first public release was August 23 2005; the most recent was June 1 2010. After I’ve updated GearHead-1 to my satisfaction I plan to do some revisions to this one as well.
  • Pascal compiler: Free Pascal
  • SDL Version: 1.2
  • Further libraries: Only those that come with the FPC compiler
  • License: LGPL
  • Open source: Yes
  • Official website: www.gearheadrpg.com

GearHead: Arena

Short description

GearHead: Arena (also known as GearHead 1) is a turn-based, rouge-like role-playing game where you can explore futuristic worlds with benign graphics.

Showcase and Basic Data

Developer granted permission to use these screenshots.

  • Project name: GearHead: Arena, also known as GearHead 1
  • Author: Joseph Hewitt, plus the work of several contributors
  • Latest version: 1.201
  • Release date: The first public release was May 10 2002; the most recent was March 3 2016. After version 1.100 I stopped development for nine years before returning to update the program earlier this year.
  • Pascal compiler: Free Pascal
  • SDL Version: 1.2
  • Further libraries: Only those that come with the FPC compiler
  • License: LGPL
  • Open source: Yes
  • Official website: www.gearheadrpg.com

 

OpenGL Logo

SDL 2.0 meets modern OpenGL

Good news, Chapter 10 has been released right now! You ever wondered what to do if you would like to create 3d graphics for a game or application? – Well, you go for modern OpenGL. And SDL 2.0 is probably the best and most convenient way to go for modern OpenGL nowadays, even professionals typically use SDL as powerful assistant for their OpenGL applications.  Learn more about the strong relationship between SDL and OpenGL in Chapter 10. – And learn how it’s done, of course ;-).

Chapter 3 got a short explanation now on how to copy the source code of a chapter. In the SDL 1.2 chapters the source code  was shipped for each chapter as Pascal file. Nowadays it is much more convenient to grab the source code (or just the desired parts) by copying it directly from the chapter’s source code boxes (in the browser) and paste it whereever it is needed.

The transfer of the old website has been finished. Nearly the complete content is in some way or another transfered to the new page. For example, all tutorial pages (even the old ones) are still available. Some downloads are integrated at the corresponding tutorial pages now, so they are not lost. Some pages are gone, these are Downloads, Tables and Links. These pages are of no benefit anymore since their information are now provided at the corresponding place instead of separate pages. Nevertheless, links trying to access these pages are redirected to the main page to prevent broken links.

No One’s Space got greenlit. This means that this Free Pascal/SDL game will be available in Steam for purchase soon. It demonstrates the power of Free Pascal and SDL.

Small update of some subdomain settings. Subdomain links work again.