PDA

View Full Version : EGSL Interpreter



Cybermonkey
22-06-2011, 04:00 PM
Hello folks,
I thought instead of introducing myself, I will introduce my active project. ;)
Actually it consists of two projects: a (simple) game engine and an IDE.
What is the EGSL interpreter? you might ask. It means "Easy Game Scripting with Lua". (Hehe, yes I like those acronyms). It's a simple engine based on SDL, SDL_gfx and SDL_mixer. Image loading is done via the Vampyre Imaging Library (to reduce the dependencies of SDL_Image). I also removed in the newest version the support for true type fonts, instead I implemented some functions to use bitmap fonts. The engine is developed in FreePascal and works on Windows and Linux. The result is a BASIC-like syntax for Lua as you can see in the screenshot.
447
This also shows the IDE which is written in FreePascal/Lazarus and also works for Windows and Linux. Maybe it's interesting to know that one can generate stand-alone executables from the scripts for distributing the games. It's also possible to use the core engine with Pascal, esp. to gain speed. I ported Lode's raycaster to the egslengine, but with Lua I got 2-3 fps, with Pascal more than 30 fps.
Since I have little freetime I am now working about 1 year on the project but I am rather pleased with the result. I am still far behind with the documentation so that will be my next priority.
448449
Shooter1945 and Space are example games for EGSL, more to read on: http://www.egsl.retrogamecoding.org/

WILL
25-06-2011, 12:44 AM
Neat! :)

Got a port for the Mac?

Cybermonkey
25-06-2011, 08:53 AM
Neat! :)

Got a port for the Mac?

Unfortunately, not. I don't have always access to a Mac. I tried it one time but had no luck. You are welcome to download the source and try to compile it. I think the IDE isn't the problem (although some paths etc. have to be changed). But I wasn't able to compile the interpreter because of some trouble with liblua.
EDIT: I don't have much experience with Mac ...

farcodev
01-07-2011, 06:40 PM
Cool work and Welcome ! ;)

WILL
02-07-2011, 12:09 AM
Question; Is EGSL written in Object Pascal or just to a generic Pascal standard?

Cybermonkey
02-07-2011, 09:28 AM
EGSL is completely procedural driven and doesn't use any OOP (if this was your question).
BTW, thanks for the presentation of EGSL on PGD News Round-up for June 2011.

Matthias
29-07-2011, 06:32 PM
That's a nice project. So if I get you right with EGSL you can script a full game only by using LUA, right?

Cybermonkey
31-07-2011, 01:47 PM
That's a nice project. So if I get you right with EGSL you can script a full game only by using LUA, right?
Yes, absolutely right. It has been done, e.g. on the showcase section of the egsl page. There is a little retro asteroids like game completely programmed using Lua.

WILL
31-07-2011, 07:41 PM
I'm sure Jeremy Darling would love your project. :) He's a bit Lua and scripting engine fan.

Cybermonkey
04-08-2011, 03:12 PM
I'm sure Jeremy Darling would love your project. :) He's a bit Lua and scripting engine fan.
Yes, I know, although I am not using his pLua unit ... ;-)

Matthias
09-08-2011, 02:02 PM
Yes, absolutely right. It has been done, e.g. on the showcase section of the egsl page. There is a little retro asteroids like game completely programmed using Lua.

That sounds great! What about the Shooter1945 game? It was also done completly in LUA with EGSL?

Cybermonkey
11-08-2011, 01:09 PM
That sounds great! What about the Shooter1945 game? It was also done completly in LUA with EGSL?
Yep, that's right.

Cybermonkey
16-01-2012, 08:58 AM
A new release was uploaded a few days ago. Some new things are:

an easy to use sprite animation system
tileset drawing functions
file management functions (I know Lua has its own but the EGSL version is easier to use.)

Haiku OS is now an officially supported operating system. Instead of the Vampyre Imaging Library which are used by Windows and Linux, Haiku relies on SDL_image. Since there is no Lazarus port for Haiku there is of course no IDE available. The examples (all in one ZIP) were updated, too.
I am still struggling with MacOSX but I still didn't manage to compile a simple Lua.pas example. I tried it with CLScript which is a kind of command line based EGSL. The source code can be found at: http://www.egsl.retrogamecoding.org//pages/downloads.php
(So if anyone has success in compiling CLScript on MacOSX, please inform me and tell me the secret how to do so.)

Stoney
16-01-2012, 12:28 PM
I am still struggling with MacOSX but I still didn't manage to compile a simple Lua.pas example.

It's not as complicated as you make it out to be. :)
Assuming you already downloaded Lua.framework and put it in /Library/Frameworks , you just need to modify a part around line 45 in Lua.pas (as by default it does not look for the Mac library).

Original code:


const
{$IFDEF UNIX}
LUA_NAME = 'liblua5.1.so';
LUA_LIB_NAME = 'liblua5.1.so';
{$ELSE}
LUA_NAME = 'lua5.1.dll';
LUA_LIB_NAME = 'lua5.1.dll';
{$ENDIF}


New code:


const
{$IFDEF UNIX}
{$IFDEF DARWIN}
LUA_NAME = 'Lua';
LUA_LIB_NAME = 'Lua';


{$linkframework Lua}
{$ELSE}
LUA_NAME = 'liblua5.1.so';
LUA_LIB_NAME = 'liblua5.1.so';
{$ENDIF}
{$ELSE}
LUA_NAME = 'lua5.1.dll';
LUA_LIB_NAME = 'lua5.1.dll';
{$ENDIF}




Some additional notes about this:
- If you need Delphi XE2 compatibility, DARWIN is not defined with Delphi XE2. You need something like {$IFDEF FPC} {$IFDEF DARWIN} {$DEFINE MACOS} {$ENDIF} {$ENDIF} and change the {$IFDEF DARWIN} in Lua.pas to {$IFDEF MACOS}
- In older code fragments, you may find {$IFDEF DARWIN} ... {$ENDIF} code to link against a dylib. This is not necessary as Darwin as an OS is not distributed separately any more, just as part of Mac OS.
- {$linkframework Lua} links against the Lua framework from code and is the same as calling fpc -Mdelphi clscript.pas -k-framework -kLua from the command-line
- Lua.framework needs to put in the app bundle when distributing the application.

Cybermonkey
16-01-2012, 01:40 PM
Thanks. I will try that as soon as I am home from work.

Cybermonkey
19-01-2012, 07:50 AM
Thanks to Stoney I managed to compile EGSL on MacOS X. First tests are promising (see the attached image). Some things are to do, though:

using Vampyre Imaging Library instead of SDL_image
porting of the IDE
creating an application bundle
If I'll have success, EGSL will run on many platforms ... ;) One only has to code a sript once and can execute it on Windows, Linux 32 bit, Linux 64 bit, Mac OS X and Haiku with the same code. 8)
693

WILL
20-01-2012, 12:51 AM
Very cool. Nice work. :)

Cybermonkey
20-01-2012, 12:46 PM
Thanks. I don't know if I already mentioned my other "project": fpBASCON. It's a simple BASIC to Pascal translator (which is rather useless for Pascal programmers ;)). But there are the things possible you can see in the attached screenshot ... in combination with my engine.

694

Cybermonkey
22-01-2012, 12:30 PM
But back to topic. I made a MacOS X binary of the game "Astrorocks" which is a simple Asteroids clone. Maybe someone with a Mac can download it and test if everything works as expected.
Download can be found here: http://www.egsl.retrogamecoding.org//pages/showcase.php
It's a rather big download because of the music included. Please use the space bar to shoot instead of left ctrl on Mac. (Because of "Spaces" ...)

Stoney
22-01-2012, 01:50 PM
It works for me. (MacBook Pro, Mac OS Lion 10.7.2 and MacBook Snow Leopar 10.6.8 )
It does not work on Leopard, that means you either compiled on Snow Leopard or you used macosx_version_min with 10.6 as its parameter. You should be able to use Leopard without any problems. (SDL and Lua are both Leopard-compatible iirc.)
You should also add a 64-bit executable to the app bundle.

On my Macbook with the integrated Intel graphics card the game is much slower than on my MacBook Pro. You definitely need to implement deltaTime for independent movement and animation speed.

Cybermonkey
22-01-2012, 02:03 PM
Thanks for testing. Yes, it was compiled on Snow Leopard. How can I create a 64-bit version with FPC? I can see no 64-bit FPC download on freepascal.org for MacOS X.
I implemented a frametimer which is set to 100 in this example. So, yes, it can run slower but it is limited to 100 fps and can not run faster than that. This example needs rather CPU power because of the pixel perfect collision and image rotation. (I don't know if SDL is hardware accelerated on MacOS). But since there is the timerticks() function, every one can add his/her own deltaTime or frame counter ...

Stoney
22-01-2012, 04:08 PM
The Mac OS X 64-bit compiler is installed by default. Instead of calling "fpc", you need to call "ppcx64". You should generate a Univeral Binary using lipo (http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/lipo.1.html). (For an example, take a look at a shell script I posted some time ago (http://www.pascalgamedevelopment.com/showthread.php?6597-Linking-Issues-on-MacOS-X-10-6-5&p=52535&viewfull=1#post52535))

I think some hardware acceleration on Mac OS X through Cocoa's drawing API is available, as I sincerely doubt it's all CPU-dependant, because it's just a difference of 370 MhZ on each core between my MacBook Pro and my MacBook. :)

Cybermonkey
22-01-2012, 04:21 PM
Oh, I see. Thanks. I'm now working on a Pacman clone, let's see what will happen if executing on different computers.
(It's really not easy to maintain 5 architectures/operating systems ...)

EDIT: Ok, I uploaded a new binary. Funny thing is that the 64 bit mode seems to be faster... Try to force 32 bit and the game runs much slower. (Maybe because I had to use a new SDL_gfx framework ...)

Cybermonkey
04-01-2013, 10:43 AM
Ok, the interpreter has now reached version 1.6.0. I switched to Lua 5.2 on Windows and Linux, Lua52.pas is included into source archive. A simple (and easy to use) particle system was added and the use of sdlmonofonts.

Cybermonkey
27-01-2013, 09:50 PM
Long promised but now I made it: a pacman clone. It's called Wallman. Wallman is a kind of a Pacman clone. If you'll play it, you'll know why I write "kind of". In contrast to the original game, Wallman is as twice as fast as the ghosts. Then there are no extra power pills who can make you strong enough to eat the ghosts. You are always chased by the them.
Fruits will appear randomly. They will be eatable for only 10 seconds, try to catch them, you'll get 150 points.
The game includes 70 levels.
Downloads are as usual on my site: http://www.egsl.retrogamecoding.org//pages/showcase.php
(Windows and Linux downloads are available at the moment, other operating systems will follow the next days.)

10681069

paul_nicholls
28-01-2013, 11:46 AM
Very nice Cybermonkey! Keep up the great work mate :)

cheers,
Paul

Cybermonkey
28-01-2013, 09:36 PM
Thanks a lot Paul.
Wallman is an example where the complete game logic is implemented in Lua. But - as earlier said - the engine is also usable in Freepascal (Bubble Chain is an example for a "pure" Pascal implementation).