I've translated the demo to FreePascal/egslengine. The source code is slightly bigger. This example is not as much faster than Lua version as in case of Mandelbrot animation (I should rather say "can't be" - when sync() is replaced with redraw()). There is no that much difference in speed of execution between Lua and FreePascal when EGSL functions are often or constantly called, but with heavy calculations (like in Mandelbrot animation) FreePascal is significantly faster.
program Demo;
uses egslengine;
var
x, y, z, k, pocz, licz, kol, stan : integer;
a, b, zx, zy, y2, x2, y3, z2, sx, sy, stan2, stan3, przes, przes2 : real;
stars1 : array[1..200] of integer;
stars2 : array[1..40] of integer;
tekst : array[1..500] of char;
muz, picture, picture2 : pointer;
tekst2 : string;
procedure animation();
begin
zx := zx + 3;
zy := zy + 3;
a := zx / 99;
b := zy / 99;
alphachannel(164);
for x := -1 to 1 do
begin
for y := -1 to 1 do
begin
for z := -1 to 1 do
begin
y2 := y;
x2 := x * cos(a) - y2 * sin(a);
y3 := x * sin(a) + y2 * cos(a);
y2 := y3;
y3 := y2 * cos(b) - z * sin(b);
z2 := y2 * sin(b) + z * cos(b);
sx := x2 * (z2 + 2);
sy := y3 * (z2 + 2);
picture2 := zoomimage(picture, (z2 + 2) / 4, (z2 + 2) / 4);
putimage(int(sx * 40 + przes), int(sy * 40 + przes2), picture2);
freeimage(picture2);
przes := przes + stan2;
przes2 := przes2 + stan3;
if (przes = 150) or (przes = 550) then
stan2 := -stan2;
if (przes2 = 160) or (przes2 = 260) then
stan3 := -stan3;
end;
end;
end;
alphachannel(255)
end;
procedure scroll();
begin
colour(kol, kol, kol);
kol := kol + stan;
if (kol >= 255) or (kol < 10) then
begin
stan := -stan;
end;
for k := 1 to 98 do
begin
drawtext((k * 8) + licz, 500, tekst[pocz + k])
end;
licz := licz - 1;
if (licz < 0) then
begin
pocz := pocz + 1;
licz := 8;
end;
if (pocz > 100 + length(tekst2)) then
begin
pocz := 1;
end;
end;
procedure stars();
begin
k := 1;
while (k <= 200) do
begin
dot(stars1[k], stars1[k + 1]);
k := k + 2;
end;
k := 1;
while (k <= 40) do
begin
fillbox(stars2[k], stars2[k + 1], stars2[k] + 1, stars2[k + 1] + 1);
k := k + 2;
end;
k := 1;
while (k <= 200) do
begin
if (stars1[k] < 798) then
stars1[k] := stars1[k] + 1
else
stars1[k] := 1;
k := k + 2;
end;
k := 1;
while (k <= 40) do
begin
if (stars2[k] < 798) then
stars2[k] := stars2[k] + 3
else
stars2[k] := 1;
k := k + 2;
end;
end;
begin
x := 0;
y := 0;
k := 0;
a := 0;
b := 0;
zx := 0;
zy := 0;
z := 0;
x2 := 0;
y2 := 0;
y3 := 0;
y3 := 0;
z2 := 0;
sx := 0;
sy := 0;
pocz := 1;
licz := 8;
kol := 10;
stan := 5;
stan2 := 0.125/2;
stan3 := 0.125/4;
przes := 500;
przes2 := 250;
tekst2 := 'Hi everybody! This is a simple demo made with FreePascal and egslengine - a very nice engine for making 2D games. It is free, open-source and multiplatform. For more information, please visit http://egsl.retrogamecoding.org/. To exit, press "Esc". Code: Tomaaz.';
for k := 1 to 100 do
begin
tekst[k] := ' ';
end;
for k := 1 to length(tekst2) do
begin
tekst[k + 100] := tekst2[k];
end;
for k := 1 to 100 do
begin
tekst[k + 100 + length(tekst2)] := ' ';
end;
k := 1;
while (k <= 200) do
begin
stars1[k] := random(799) + 1;
stars1[k + 1] := random(450) + 20;
k := k + 2;
end;
k := 1;
while (k <= 40) do
begin
stars2[k] := random(799) + 1;
stars2[k + 1] := random(450) + 20;
k := k + 2;
end;
openwindow(800, 519, 0, 'Simple demo');
setframetimer(50);
backcolour(0, 0, 0);
muz := loadmusic('1.ogg');
picture := loadimage('1.png');
colourkey(0, 0, 0);
playmusic(muz, 99, -1);
repeat
clearscreen();
colour(255, 255, 255);
stars();
animation();
scroll();
colour(int((255 - kol) / 4 + 64), int((255 - kol) / 4 + 64), 0);
fillbox(0, 0, 799, 19);
fillbox(0, 515, 799, 518);
fillbox(0, 471, 799, 490);
colour(0, 0, 0);
fillbox (5, 499, 20, 514);
fillbox (779, 499, 799, 514);
sync();
until (getkey() = 27);
end.
Source code, Windows executable and all required files are attached.