I am coding two games in Lazarus as a teaching aide for learning Object Pascal. I am using Linux Mint as the machine and Lazarus 2.0.10 as the IDE.
The games are a MineSweeper game and a MahJong Solitaire game. The MineSweeper game is much further along (almost complete), and has multiple units and three forms (main, settings, and instructions). The Mahjong Solitaire game is barely started, has only one form and 4 total procedures in it. More graphics are in the MineSweeper game compared with Mahjong Solitaire (225k vs. 198k), yet the optimized compile size of MineSweeper is 3.6MB, and the Mahjong Solitaire is 6.4MB with barely anything in it. This seemed strange so I compiled an empty "project1" project and it came out 6.4MB.
Now MineSweeper was started on 2.0.8, but it still compiles much smaller on 2.0.10. The optimizations are the same (No Debug info at all, no range check etc., smallest compile size, and level 4 optimizations. This isn't a deal breaker regarding the use of Lazarus, but it is a curious and somewhat maddening thing I can't explain. Of course I want the newer game to be more in line with the older one I am working on.
Here's the top of MineSweeper:
unit main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, ExtCtrls,
StdCtrls, Menus, gmStructs, Init;
type
{ TgmForm }
TgmForm = class(TForm)
xMenu: TMainMenu;
Instructions: TMenuItem;
Settings: TMenuItem;
Timer: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: char);
procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure FormPaint(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure InstructionsClick(Sender: TObject);
procedure SettingsClick(Sender: TObject);
procedure TimerTimer(Sender: TObject);
private
public
procedure ShowHead;
procedure ShowMain;
procedure ShowMine;
procedure InitGame;
end;
var
gmForm : TgmForm;
seconds : integer;
FirstMove: Boolean;
implementation
{$R *.lfm}
and here's MahJong Solitaire so far:
unit gamefrm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Graphics;
type
TVec = record
x: byte;
y: byte;
z: byte;
end;
{ TForm1 }
TForm1 = class(TForm)
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
procedure Init();
public
end;
var
Form1: TForm1;
gmBackground: TPortableNetworkGraphic;
gmTiles: TPortableNetworkGraphic;
field: array [0..50, 0..40, 0..5] of byte;
// x y z
Moves: array of TVec;
const
//width and height of tiles
tWidth = 48;
tHeight = 66;
stepX = tWidth div 2 - 2;
stepY = tHeight div 2 - 2;
offX = 4;
offY = 6;
implementation
{$R *.lfm}