Lazarus

Programming => Graphics and Multimedia => Games => Topic started by: Ñuño_Martínez on May 10, 2016, 08:55:20 pm

Title: Allegro.pas
Post by: Ñuño_Martínez on May 10, 2016, 08:55:20 pm
Allegro.pas (http://allegro-pas.sf.net/) is a wrapper that allows to use the Allegro Game Library (http://liballeg.org/) with Pascal.

Allegro.pas 5.2.alpha released!  8)

Yep, about 3 years after 5.0.alpha, a new release of branch 5 (now TRUNK) was released today.  It has a lot of improvements, and should be slightly more stable than previous alpha.  But it is still an alpha.  :-[ Anyway, if you want to test it, download from here (https://sourceforge.net/projects/allegro-pas/files/5.2.alpha/).

I'll use it in the comming TINS 2016 (http://tins.amarillion.org/), and I plan to use my entry as demonstration game for the library.

Note:  I'll do release announcementes in this thread from now, instead of create a new thread every version.
Title: Allegro.pas 5.2.alpha-2
Post by: Ñuño_Martínez on June 26, 2016, 08:15:25 pm
There are a lot of work to be done yet, but I did several big improvements so I've just uploaded a new release.

In short:  There are several bugfixing, including (but not limited to) the primitives add-on that didn't work in previous versions.  There are new functionality too, as 3D transformations and custom memory management.  Also I added new examples and updated some other that shows how to use basic and advanced stuff to supply the lack of documentation.

You can download it from here (https://sourceforge.net/projects/allegro-pas/files/5.2.alpha/).

Any comment and suggestion will be welcome.
Title: Re: Allegro.pas
Post by: johnsson on June 26, 2016, 09:24:13 pm
Excellent work.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on June 27, 2016, 01:41:49 pm
Thanks. :)

Now I'm wondering what would be a good demonstration game to be added.  :-\
Title: Re: Allegro.pas
Post by: Leledumbo on June 27, 2016, 06:45:50 pm
Thanks. :)

Now I'm wondering what would be a good demonstration game to be added.  :-\
Something achievable in a relatively short code. People tend to learn from examples these days, and I think providing a tutorial is also much harder than providing ready to run examples. The first 3 starter examples could be:
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on June 29, 2016, 01:40:37 pm
Something achievable in a relatively short code. People tend to learn from examples these days, and I think providing a tutorial is also much harder than providing ready to run examples. The first 3 starter examples could be:
  • tic-tac-toe or 15 puzzle (2d, no animation, no collision detection)
  • arkanoid (2d, simple linear animation, simple collision detection by position checking)
  • simplified 1945 / raiden (2d, a bit complex animation, bounding square/circle/triangle collision detection)
Not bad. I like it. Thanks.
Title: Allegro.pas 4.4.5-1
Post by: Ñuño_Martínez on July 20, 2016, 01:43:35 pm
Some days ago somebody found that unit alWin didn't compile.  Since I never used it, I didn't tested.

Anyway it is now fixed. I've also upgraded documentation adding a search engine.
Title: Re: Allegro.pas
Post by: Handoko on July 20, 2016, 04:01:15 pm
I will suggest Tetris to replace Tic Tac Toe. I personally think Tic Tac Toe is boring, Tetris is challenging. But Tic Tac Toe as demo game has it own value, that is to demonstrate simple AI.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on July 21, 2016, 11:44:44 am
Agree.  I think I'll do a Tetris-like delphi (I like Puyo-puyo (https://www.youtube.com/watch?v=Gq0U-ml1HS4) :)) and a shooter.  One of them with 3D graphics even if they are 2D games.  That will show and teach a lot.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on July 06, 2017, 11:16:48 am
Oh my oh my!  More than one year since the last release (5.2.alpha2).

But that's not the worst part, no it isn't.  The worst part is that I did a ton of improvements.  Mostly documentation but also:
If you're wondering why I didn't release 5.2.alpha3 yet the answer is simple:  I forgot it.  Last year I had a lot of personal and laboral issues that affected my memory.  Really.  I'll release it this evening or tomorrow.  I'll not do it now because I'm busy (I really am ::) ) and because I've found a flaw in the SVN tree I must fix too (There isn't 5.2.alpha in the RELEASE directory!).
Title: Allegro.pas 5.2.a3
Post by: Ñuño_Martínez on July 06, 2017, 09:35:43 pm
Ok: I just uploaded the new 5.2.a3 release.  Please enjoy (https://sourceforge.net/projects/allegro-pas/files/5.2.a3/).
Title: Re: Allegro.pas
Post by: timofonic on July 18, 2017, 03:15:17 am
Just a question:

Why using Allegro instead of SDL2? What are the reasons behind it?
Title: Re: Allegro.pas
Post by: Handoko on July 18, 2017, 07:31:52 am
Hello timofonic,
Welcome to the forum.

If you google the web you will find no winner, none of them has its own killer feature. Both of them are good libraries for game creation, and finding tutorials are very easy.

I've just started to learn Allegro some months ago. I found Allegro is very easy to start with. SDL API documentation is good, but Allegro is better. Allegro API pages offer more info, including see also and examples.

You can compare load bitmap documentation of SDL:
http://wiki.libsdl.org/SDL_LoadBMP?highlight=%28\bCategorySurface\b%29

With this:
https://www.allegro.cc/manual/5/al_load_bitmap

Furious Paladin is my first test project using Allegro:
http://forum.lazarus.freepascal.org/index.php/topic,35313.msg252085.html#msg252085

It had some minor issues, my problem not allegro's problem. It didn't run on same speed on different machines, solved easily. Later I found on Windows it didn't detect shift keys the same way on Linux. I modified the code to use ctrl keys instead of shift keys.

The demo was created using 500 x 300 pixels resolution. It is not good for large screen users. As recommended by some users here, I tried to make it better supports on large screen. I never thought it was so easy to make it double size if it detects running on large screen. Just added the code below then the program will display double sized without changing anything of the code.

Code: Pascal  [Select]
  1. const
  2.   ScreenWidth  = 500;
  3.   ScreenHeight = 300;
  4.  
  5. var
  6.   Display:     ALLEGRO_DISPLAYptr;
  7.   MonitorInfo: ALLEGRO_MONITOR_INFO;
  8.   Transform:   ALLEGRO_TRANSFORM;
  9.  
  10.   // Prepare display
  11.   al_get_monitor_info(0, MonitorInfo);
  12.   if (MonitorInfo.x2 > 1060) and (MonitorInfo.y2 > 610) then begin
  13.     Display := al_create_display(ScreenWidth*2, ScreenHeight*2);
  14.     al_identity_transform(Transform);
  15.     al_rotate_transform(Transform, 0);
  16.     al_scale_transform(Transform, 2, 2);
  17.     al_use_transform(Transform);
  18.   end
  19.   else
  20.     al_create_display(ScreenWidth, ScreenHeight);

I have not tried SDL, I cannot say Allegro is better. But I can say Allegro is really easy to start with.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on July 18, 2017, 10:03:56 am
I think the main reasons to use Allegro instead of SDL are personal preferences.

Both libraries have support for (most) modern platforms.  Allegro is less popular than SDL, so there are less examples, tutorials and games (the awesome Factorio (https://www.factorio.com/) was made using Allegro) but me and others are working hard to change this.
Title: Allegro.pas 5.2.b.0 released
Post by: Ñuño_Martínez on April 23, 2018, 08:54:10 pm
[This is a copy of what I wrote for the news (https://www.sourceforge.net/p/allegro-pas/news/2018/04/allegropas-52b0-released/) section of SourceForge.  I'm a bit lazy today.]

Almost a year after the last release I've published version 5.2.b.0.

This version doesn't fix a lot of bugs nor adds new functionality, but it is an important milestone (hence the change from alpha to beta) as to recover Delphi compatibility.

May be you know, Allegro.pas was Delphi compatible from the beginning.  It was quite complex because Allegro API needed to share variables with DLL, and Delphi wasn't capable of this.  To make it possible, I used an extra DLL file that returned the pointers to such variables.  That made things quite complex to maintain and hard to use so I decided to remove Delphi compatibility being the latest compatible version the 4.2.2 but I always promised the back to Delphi with version 5 as the new API is more easy to port.

Now Delphi compatibility has back.  Unfortunatelly I wasn't able to make it 100% compatible yet and a few examples don't work but they will.  Also it was tested with Delphi 10 Tokio Starter Edition only.  I've try to keep track of older versions (thanks to Gregor A. Cieslak for his help) but it may fail.  Please let me know.

Visit the Files section (https://sourceforge.net/projects/allegro-pas/files/5.2.b.0/) to download and test this new version.  I've updated the on-line documentation (http://allegro-pas.sourceforge.net/docs/5.2/) that you can download from the Files section too.
Title: Re: Allegro.pas
Post by: dubst3pp4 on November 08, 2018, 07:31:19 am
Hi Ñuño_Martínez, thanks for your great work!

I'm testing the Allegro.pas bindings for a new project and figured out, that the latest sources (allegro.pas-5.2.b.0) don't build on Linux, whereas allegro.pas-5.2.a.3 builds fine. I've installed allegro 5.2.3.0 from the Ubuntu repositories. After I type make the linker tells me the following:
Quote
Allegro.pas 5.2.b
(c) Guillermo Martínez J. 2006-2017
http://allegro-pas.sourceforge.net

fpc -O- -gl -vh -vw -dDEBUGMODE -Sh -Si  -Fulib/ -FUobj/ examples/ex_bitmap_flip.pas -obin/examples/ex_bitmap_flip
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 3.0.4 [2017/12/13] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling examples/ex_bitmap_flip.pas
Linking bin/examples/ex_bitmap_flip
/usr/bin/ld: warning: bin/examples/link.res contains output sections; did you forget -T?
/usr/bin/ld: -lallegro-debug was not found
/usr/bin/ld: -lallegro_image-debug was not found
/usr/bin/ld: -lallegro_font-debug was not found
/usr/bin/ld: -lallegro_dialog-debug was not found
Error: Error while linking
Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode
makefile.all:20: recipe for target 'bin/examples/ex_bitmap_flip' failed
make: *** [bin/examples/ex_bitmap_flip] Error 1
It seems that the allegro_*-debug files weren't referenced with the previous version of allegro.pas, weren't they? Do I miss something important when I use allegro.pas-5.2.a.3?

Thanks for any hints :-)
Title: Re: Allegro.pas
Post by: Soner on November 08, 2018, 03:53:11 pm
You must install allegro development package.
Install synaptic package program and search with it.
It has same name plus...-dev...


Look at this lines from compile result:

usr/bin/ld: -lallegro-debug was not found
/usr/bin/ld: -lallegro_image-debug was not found
/usr/bin/ld: -lallegro_font-debug was not found
/usr/bin/ld: -lallegro_dialog-debug was not found



Linker tells to you that some libs are missing.
Look for the name -lxxxxx in synaptic.
I.e for -lallegro_image is something like liballegro_image...-dev
Title: Re: Allegro.pas
Post by: dubst3pp4 on November 08, 2018, 04:00:54 pm
You must install allegro development package.
Install synaptic package program and search with it.
It has same name plus...-dev...
I've installed them already, that's why I was able to build the examples with 5.2.a.3 but not with the latest version (5.2.b.0).
Title: Re: Allegro.pas
Post by: Soner on November 08, 2018, 04:24:09 pm
The linker tells you have not installed them. Maybe your program is 32 bit and your allegro 64bit,or lib names are changed in allegro.pas 5.2.b.0.
I would compare library names in both versions.
Good luck.
Title: Re: Allegro.pas
Post by: dubst3pp4 on November 09, 2018, 08:21:36 am
Hi Soner,
thanks for your input. I found out that it was no problem to compile the demo game by Handoko, which is included in the latest allegro.pas. So the problem had to be in the makefile and voilà, in the file there are the following lines:

Code: [Select]
# Optimized compilation
# FLAGS = $(OPTOPT) $(PFLAGS) $(EFLAGS)
# Use next line instead to activate debug.
FLAGS = $(DBGOPT) $(PFLAGS) $(EFLAGS)

which I changed to

Code: [Select]
# Optimized compilation
FLAGS = $(OPTOPT) $(PFLAGS) $(EFLAGS)
# Use next line instead to activate debug.
# FLAGS = $(DBGOPT) $(PFLAGS) $(EFLAGS)

and now all the examples compile fine. Neither on Ubuntu nor on Fedora there are *-debug versions of allegro5, just the -dev packages.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on November 09, 2018, 06:21:49 pm
That's weird.  I can compile it in my Linux system (Xubuntu 16.04, should upgrade and test  %)).  May be they changed something in the names, but I don't think so.  Or am I using a different version?  I'll take a look and update if needed. Thanks dubst3pp4.

BTW I'm working in the documentation (slowly because I don't have a lot of free time, and also I want to do something for GitHub Game Off (https://itch.io/jam/game-off-2018)) checking the whole library line per line comparing with the original Allegro.  This is also to find potential (API) bugs and also to know what stuff are not implemented yet.

[Edit]
I've created a bug ticket (https://sourceforge.net/p/allegro-pas/bugs/18/) just to keep track and not forget it.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on November 22, 2018, 07:41:35 pm
Finally I found time to try and it didn't go well.

I updated Xubuntu Linux to 18.04.1 so I had to re-install Allegro but something goes wrong.  Allegro does work perfect but when I try Allegro.pas examples I have some unhandled exceptions when exiting.  Also I've found I can't compile my own game engine (mingro on SourceForge) because some issues with the library that deals with PNG files.  This is specially weird s Allegro.pas examples compile perfectly.

This is weird so I think I'll reinstall Linux.  This isn't the first time that Ubuntu update doesn't do the work correctly.
Title: Re: Allegro.pas
Post by: lainz on November 24, 2018, 05:12:06 pm
I think a good port with Allegro can be Open Surge
http://opensnc.sourceforge.net/forum/

Now it has his own scripting engine as well.

I think they was using Allegro 4, but now I don't know. I never get to compile their code, I'm not good using 'make' and similar tools, getting things working in the C world seems harder that installing everything with packages / OPM.

Anyways is a good allegro game, that will be cool to have in Pascal. I some time started a port to JS, to discover that a port to JS was already available  ::)
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on November 27, 2018, 11:17:57 am
I think a good port with Allegro can be Open Surge
http://opensnc.sourceforge.net/forum/
Yep, I know that project too.  Actually I plan to add some ideas from it to my engine, such some of the scripting stuff to help defining tilesets and spritesheets.
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on November 27, 2018, 06:14:21 pm
Ok, with a clean Linux installation it seems to work, and I think I've found what's the problem found by dubst3pp4:

-dev packages provided by Ubuntu doesn't includes the library compiled with "debug" option.  The only way to get such library is to download sources and compile by yourself.  I'll add a note to the installation instructions.
Title: Re: Allegro.pas
Post by: lucamar on November 27, 2018, 08:53:29 pm
[...] Ubuntu doesn't includes the library compiled with "debug" option.  The only way to get such library is to download sources and compile by yourself.  I'll add a note to the installation instructions.

Yeah, my Kubuntu hasn't got any "-debug" package:
Code: Bash  [Select]
  1. lucamar@luna:~$ apt list *allegro*
  2. Listing... Done
  3. allegro4-doc/trusty 2:4.4.2-4 all
  4. allegro5-doc/trusty 2:5.0.10-2 all
  5. liballegro-acodec5-dev/trusty 2:5.0.10-2 i386
  6. liballegro-acodec5.0/trusty 2:5.0.10-2 i386
  7. liballegro-audio5-dev/trusty 2:5.0.10-2 i386
  8. liballegro-audio5.0/trusty 2:5.0.10-2 i386
  9. liballegro-dialog5-dev/trusty 2:5.0.10-2 i386
  10. liballegro-dialog5.0/trusty 2:5.0.10-2 i386
  11. liballegro-doc/trusty 2:4.4.2-4 all
  12. liballegro-image5-dev/trusty 2:5.0.10-2 i386
  13. liballegro-image5.0/trusty 2:5.0.10-2 i386
  14. liballegro-physfs5-dev/trusty 2:5.0.10-2 i386
  15. liballegro-physfs5.0/trusty 2:5.0.10-2 i386
  16. liballegro-ttf5-dev/trusty 2:5.0.10-2 i386
  17. liballegro-ttf5.0/trusty 2:5.0.10-2 i386
  18. liballegro4-dev/trusty 2:4.4.2-4 i386
  19. liballegro4.4/trusty 2:4.4.2-4 i386
  20. liballegro4.4-plugin-alsa/trusty 2:4.4.2-4 i386
  21. liballegro5-dev/trusty 2:5.0.10-2 i386
  22. liballegro5.0/trusty 2:5.0.10-2 i386
  23. libguichan-allegro-0.8.1-1/trusty 0.8.2-13 i386
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on November 28, 2018, 11:05:03 am
I was re-thinking it.  The "-debug" versions are to debug Allegro itself.  So they're not actually needed when working in your game, but it is useful when working on Allegro.pas or creating a new add-on.  So, to not link the "-debug" version just remove the "-dDEBUGMODE" option from the makefile (just line 85 (https://sourceforge.net/p/allegro-pas/code/HEAD/tree/RELEASES/5.2.b.0/makefile#l85)) and/or use the optimized  configuration as dubst3pp4 said (lines 114 to 117 (https://sourceforge.net/p/allegro-pas/code/HEAD/tree/RELEASES/5.2.b.0/makefile#l114))

This will be "fixed" in the next release, including the documentation explaining it.  I don't know when it will be released but I doubt it will be before next year (too little time :().
Title: Re: Allegro.pas
Post by: dubst3pp4 on November 28, 2018, 12:06:11 pm
Ok, with a clean Linux installation it seems to work, and I think I've found what's the problem found by dubst3pp4:

-dev packages provided by Ubuntu doesn't includes the library compiled with "debug" option.  The only way to get such library is to download sources and compile by yourself.  I'll add a note to the installation instructions.
Thanks Ñuño! When I compile without the DBGOPT flags, everything works also without the -debug packages. For what do I need those debug packages? To get a proper support of Allegro.pas in gdb?
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on November 29, 2018, 12:08:48 pm
Thanks Ñuño! When I compile without the DBGOPT flags, everything works also without the -debug packages. For what do I need those debug packages? To get a proper support of Allegro.pas in gdb?
The -debug packages are to debug Allegro, so yes, they're to debug Allegro.pas with GDB too.  They're not needed to debug your games.  Now I have to test if -dev packages are mandatory or if it can work with the release ones.
Title: Re: Allegro.pas
Post by: knerking@gmail.com on May 12, 2019, 03:53:33 am
I just like to thank you for your work with allegro5. I works very well.  8)
Title: Re: Allegro.pas
Post by: Ñuño_Martínez on May 13, 2019, 11:21:40 am
I just like to thank you for your work with allegro5. I works very well.  8)
Thank you for using it. ;)

Curiously, I came to write something.

Few days ago I finished to revise the allegro5.pas (https://sourceforge.net/p/allegro-pas/code/HEAD/tree/TRUNK/lib/allegro5.pas) unit.  It was a loooooong work, checking everything and updating the documentation.  As a result, documentation is complete for that unit, and I've fixed some mistakes, changed a few stuff (data types, parameters...) and added a few new procedures and functions.

I've also spend some time trying to update the website, but was not able to change the background color (sigh!).  I think I'll create a new one, but not yet.  A month ago I created a new project to help build websites for SourceForge projects called sfwebsite (https://sfwebsite.sourceforge.io/).  It's still in a very early stage but once finished it will help a lot.

So, I'll not upload a new version soon, as there's work to do:

But I'm in the way...
Title: Still alive...
Post by: Ñuño_Martínez on November 14, 2019, 09:38:53 pm
Still alive and working on the project.

Two days ago I've finished to check all addons and documentation.  Right now I'm working porting more examples from the original Allegro.  This will show me if there's still any mistake or error.

Also, I've synced the GitHub mirror (https://github.com/niuniomartinez/allegro-pas) if you don't like SourceForge.