Recent

Author Topic: Pac-Mac: a clone of the original game  (Read 4698 times)

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #30 on: January 30, 2026, 05:59:57 pm »
Yep, now I have sound, after doing this:

Code: Pascal  [Select][+][-]
  1. $ sudo apt-get install libopenal-dev
  2. $ sudo apt-get install libsndfile-dev

 ;D

And very nice project. :)
I'm happy it work now, but you still have the small window size.
The cross-platform things is very frustrating for someone like me that not have the knowledge...! %)
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #31 on: January 30, 2026, 06:06:36 pm »
However, I found the best way to play it on my mactine is to cross-compile to win64 and just use wine to run it :)
The sound works out of the box, the screen looks great, then game plays nearly flawless

Does the game window occupy the whole screen under Wine ?
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Fred vS

  • Hero Member
  • *****
  • Posts: 3873
    • StrumPract is the musicians best friend
Re: Pac-Mac: a clone of the original game
« Reply #32 on: January 30, 2026, 06:15:19 pm »
The cross-platform things is very frustrating for someone like me that not have the knowledge...! %)

If you agree I will jump into it and adapt all for Linux, FreeBSD, OpenBSD, NetBSD, DragonFlyBSD.

( And because I am fan of out-of-the-box project I will do a u_uos_audio.pas to have sound working ootb for all os ).
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Nimbus

  • Jr. Member
  • **
  • Posts: 87
Re: Pac-Mac: a clone of the original game
« Reply #33 on: January 30, 2026, 06:29:46 pm »
Does the game window occupy the whole screen under Wine ?

Yep - stretched and properly scaled to cover all of desktop.
Contrary to native Linux builds I tried (gtk2, qt5, qt6), which all open a tiny window, too small for my screen.
Perhaps the window could resizable, if it's not too much pain?

Fred vS

  • Hero Member
  • *****
  • Posts: 3873
    • StrumPract is the musicians best friend
Re: Pac-Mac: a clone of the original game
« Reply #34 on: January 30, 2026, 07:23:53 pm »
Hello.

With this, I have perfect result on Linux:

Code: Pascal  [Select][+][-]
  1. procedure TFormMain.FormCreate(Sender: TObject);
  2. var
  3.   BoundsRect_client: TRect;
  4. begin
  5. {$ifdef MAXIMIZE_SCENE_ON_MONITOR}
  6.   FScene := TOGLCScene.Create(OpenGLControl1, SCREEN_WIDTH_AT_DESIGN_TIME/SCREEN_HEIGHT_AT_DESIGN_TIME);
  7.  {$ifdef WINDOWED_MODE}
  8.  BoundsRect_client := Monitor.BoundsRect;
  9.  BoundsRect_client.Width:= Monitor.BoundsRect.width - 100 ;
  10.  BoundsRect_client.left:= 50;
  11.  BoundsRect_client.height:= Monitor.BoundsRect.height - 100 ;
  12.  BoundsRect_client.top:= 50;
  13.  BoundsRect := BoundsRect_client;
  14.  WindowState := wsNormal;      
  15.  {$else}
  16.   BorderIcons := [];
  17.   BorderStyle := bsNone;
  18.   WindowState := wsFullScreen;
  19.   BoundsRect := Monitor.BoundsRect;
  20.  {$endif}
  21. {$else}
  22.   ...
  23.  ....

Maybe a feature to quit the game with Ctrl+Q key would be nice, mainly if the game is not in WINDOWED_MODE.

Very nice game, video is fluent and sound is perfect. well done Lulu.  ;D

[EDIT] Fixed code {$ifndef WINDOWED_MODE} must be {$ifdef WINDOWED_MODE}, was used for testing.
« Last Edit: January 30, 2026, 08:48:05 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #35 on: January 30, 2026, 08:07:48 pm »
The cross-platform things is very frustrating for someone like me that not have the knowledge...! %)

If you agree I will jump into it and adapt all for Linux, FreeBSD, OpenBSD, NetBSD, DragonFlyBSD.

( And because I am fan of out-of-the-box project I will do a u_uos_audio.pas to have sound working ootb for all os ).

Of course Fred, thank you very much for that  :)
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #36 on: January 30, 2026, 08:24:10 pm »
Does the game window occupy the whole screen under Wine ?

Yep - stretched and properly scaled to cover all of desktop.
Contrary to native Linux builds I tried (gtk2, qt5, qt6), which all open a tiny window, too small for my screen.
Perhaps the window could resizable, if it's not too much pain?
It is, because in OGLCScene, all graphics are from vectorial (svg file), and when they are rasterized in a texture atlas at run time, their size is computed according the scene size, which is maximized with the right aspect ratio in the window.
If the window size change while the game is running, the system have to rebuild the atlas, this is the problem.
I've choosen this approach to exploit svg capabilities to have the maximum graphics detail, whatever the player screen resolution.
This wasn't the easiest approach!  :D
« Last Edit: January 30, 2026, 08:50:27 pm by Lulu »
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Fred vS

  • Hero Member
  • *****
  • Posts: 3873
    • StrumPract is the musicians best friend
Re: Pac-Mac: a clone of the original game
« Reply #37 on: January 30, 2026, 08:27:33 pm »
The cross-platform things is very frustrating for someone like me that not have the knowledge...! %)

If you agree I will jump into it and adapt all for Linux, FreeBSD, OpenBSD, NetBSD, DragonFlyBSD.

( And because I am fan of out-of-the-box project I will do a u_uos_audio.pas to have sound working ootb for all os ).

Of course Fred, thank you very much for that  :)

Great!

For the size of the window of the game, for Linux I am very happy with the code from my previous post, but maybe for Windows your original code is better.
If so, some
Code: Pascal  [Select][+][-]
  1. {$IFDEF unix}
  2. do this
  3. {$ELSE}
  4. do that
  5. {$ENDIF}
     
are neeeded.

And about u_uos_audio.pas, sorry I did not catch that ALsound is one of your package, it works great (when the dependencies are installed in the system).
But for the fun I will try to do u_uos_audio.pas that uses portaudio +libsndfile both dynamically loaded and ready for Linux (included on arm), FreeBSD,  OpenBSD, NetBSD.             
« Last Edit: January 30, 2026, 08:49:55 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #38 on: January 30, 2026, 08:49:08 pm »
You're right, the code is now
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.FormCreate(Sender: TObject);
  2. {$ifdef unix}var BoundsRect_client: TRect;{$endif}
  3. begin
  4. {$ifdef MAXIMIZE_SCENE_ON_MONITOR}
  5.   FScene := TOGLCScene.Create(OpenGLControl1, SCREEN_WIDTH_AT_DESIGN_TIME/SCREEN_HEIGHT_AT_DESIGN_TIME);
  6.  {$ifdef WINDOWED_MODE}
  7.    {$ifdef unix}
  8.      BoundsRect_client := Monitor.BoundsRect;
  9.      BoundsRect_client.Width := Monitor.BoundsRect.width - 100;
  10.      BoundsRect_client.height := Monitor.BoundsRect.height - 100;
  11.      BoundsRect := BoundsRect_client;
  12.      WindowState := wsNormal;
  13.    {$else}
  14.      WindowState := wsMaximized;
  15.      BorderIcons := [biSystemMenu,biMinimize,biMaximize];
  16.    {$endif}
  17.  {$else}
  18.   BorderIcons := [];
  19.   BorderStyle := bsNone;
  20.   WindowState := wsFullScreen;
  21.   ShowWindow(Handle, SW_SHOWFULLSCREEN);
  22.   BoundsRect := Monitor.BoundsRect;
  23.  {$endif}
  24. {$else}
  25. ...
  26.  

"IFDEF UNIX" include also macOS or not ? (I known for macOS we use "ifdef darwin")

And about u_uos_audio.pas, sorry I did not catch that ALsound is one of your package, it works great (when the dependencies are installed in the system).
But for the fun I will try to do u_uos_audio.pas that uses portaudio +libsndfile both dynamically loaded and ready for Linux (included on arm), FreeBSD,  OpenBSD, NetBSD.             
This is not a problem :) I had an interest to OpenAL since years now, before I known the existence of OpenAL-Soft. And I have tested UOS, it is great.
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Fred vS

  • Hero Member
  • *****
  • Posts: 3873
    • StrumPract is the musicians best friend
Re: Pac-Mac: a clone of the original game
« Reply #39 on: January 30, 2026, 08:58:57 pm »
"IFDEF UNIX" include also macOS or not ? (I known for macOS we use "ifdef darwin")
Yes, MacOS is a Unix operating system and is recognized as such by fpc.

the code is now
Maybe you may add also the position top, left, like in the updated post:
Code: Pascal  [Select][+][-]
  1. {$ifdef WINDOWED_MODE}
  2.  BoundsRect_client := Monitor.BoundsRect;
  3.  BoundsRect_client.Width:= Monitor.BoundsRect.width - 100 ;
  4.  BoundsRect_client.left:= 50;  // add this
  5.  BoundsRect_client.height:= Monitor.BoundsRect.height - 100 ;
  6.  BoundsRect_client.top:= 50;  // add this
  7.  BoundsRect := BoundsRect_client;
  8.  WindowState := wsNormal;      
  9.  {$else}

« Last Edit: January 30, 2026, 09:05:57 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #40 on: January 30, 2026, 09:05:19 pm »
done.
Why did you substract 100 pixel from the monitor size ?
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Fred vS

  • Hero Member
  • *****
  • Posts: 3873
    • StrumPract is the musicians best friend
Re: Pac-Mac: a clone of the original game
« Reply #41 on: January 30, 2026, 09:13:45 pm »
Why did you substract 100 pixel from the monitor size ?

Otherwise, part of the window is hidden by the window manager's system panel.

Of course, -100 is an arbitrary value and could correspond to the size of the system panel, but determining its exact dimensions and location is more complex, as they depend on the installed window manager.

In short, -50 should also work.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #42 on: January 30, 2026, 09:15:59 pm »
ok, thanks for the precision
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Lulu

  • Sr. Member
  • ****
  • Posts: 405
Re: Pac-Mac: a clone of the original game
« Reply #43 on: February 03, 2026, 01:13:31 pm »
Hi All,
Thanks to Fred vS, Nimbus and Roland, I've changed the code to resize the window for each platform. Now the code is:
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.FormCreate(Sender: TObject);
  2. {$ifdef Linux}var BoundsRect_client: TRect;{$endif}
  3. begin
  4. {$ifdef MAXIMIZE_SCENE_ON_MONITOR}
  5.   FScene := TOGLCScene.Create(OpenGLControl1, SCREEN_WIDTH_AT_DESIGN_TIME/SCREEN_HEIGHT_AT_DESIGN_TIME);
  6.  {$ifdef WINDOWED_MODE}
  7.    // WINDOWED MODE
  8.    {$if defined(Linux)}
  9.      BoundsRect_client := Monitor.BoundsRect;
  10.      BoundsRect_client.Width := Monitor.BoundsRect.width - 100;
  11.      BoundsRect_client.left:= 50;
  12.      BoundsRect_client.height := Monitor.BoundsRect.height - 100;
  13.      BoundsRect_client.top:= 50;
  14.      BoundsRect := BoundsRect_client;
  15.      WindowState := wsNormal;
  16.    {$elseif defined(Windows)}
  17.      WindowState := wsMaximized;
  18.      BorderIcons := [biSystemMenu, biMinimize, biMaximize]; // necessary to see the task bar
  19.    {$elseif defined(Darwin)}
  20.      BorderIcons := [biSystemMenu,biMinimize];
  21.      BoundsRect := Monitor.BoundsRect;
  22.    {$endif}
  23.  
  24.  {$else}
  25.    // FULLSCREEN MODE
  26.    {$if defined(Windows) or defined(Linux)}
  27.      BorderIcons := [];
  28.      BorderStyle := bsNone;
  29.      WindowState := wsFullScreen;
  30.      ShowWindow(Handle, SW_SHOWFULLSCREEN);
  31.      BoundsRect := Monitor.BoundsRect;
  32.    {$elseif defined(Darwin)}
  33.      BoundsRect := Monitor.BoundsRect;
  34.    {$endif}
  35.  {$endif}
  36. {$else}
  37.      // WINDOWED MODE WITH FIXED SIZE
  38.      ClientWidth := Trunc(SCREEN_WIDTH_AT_DESIGN_TIME);
  39.      ClientHeight := Trunc(SCREEN_HEIGHT_AT_DESIGN_TIME);
  40.      FScene := TOGLCScene.Create(OpenGLControl1, -1);
  41.      BorderIcons := [biSystemMenu];
  42.      BorderStyle := bsSingle;
  43.      WindowState := wsNormal;
  44. {$endif}
  45. ...
  46.  
Tested on Windows and VM Light Ubuntu 24.04 Noble Numbat. The code work for both windowed mode, fullscreen mode and window with fixed size mode.
For the moment, on macOS the window have the same size as the monitor for both mode. I tryed the full screen mode explained at https://wiki.lazarus.freepascal.org/macOS_Programming_Tips#Launch/Toggle_full_screen without success: fpc give an internal error when using the {$modeswitch objectivec1} directive on my VM Catalina machine.

Here https://github.com/bastibe/libsndfile-binaries there is a script to compile libsndfile.so library without dependency (the previous .so provided with the game had a dependency with Flac). I've used this script and recompiled the libsndfile.so on a VM Ubuntu 20.04. ldd command say no dependency. The lib was tested on the VM LUbuntu 24.04, it work.
The game is updated.

Thanks again to Fred vS, Nimbus and Roland for their help !
« Last Edit: February 03, 2026, 01:18:18 pm by Lulu »
wishing you a nice life!
GitHub repositories https://github.com/Lulu04

Fred vS

  • Hero Member
  • *****
  • Posts: 3873
    • StrumPract is the musicians best friend
Re: Pac-Mac: a clone of the original game
« Reply #44 on: February 03, 2026, 01:27:33 pm »
Hi Lulu.

I created an issue (which I closed because it wasn't a issue): https://github.com/Lulu04/PacMan/issues/1 regarding the use of uos as an optional audio engine.

It's mostly for fun; your ALSound works perfectly (but OpenAL requires many dependencies that can't be easily loaded dynamically under Unix, for example on my Ubuntu Noble, I needed to install libsndfile with :
Code: Pascal  [Select][+][-]
  1. $ sudo apt-get install libsndfile-dev
otherwise ALSound can not load it, even if dynlibs.LoadLibrary('path-to-libsndfile.so') is used.)
« Last Edit: February 03, 2026, 02:24:25 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018