From Delphi XE6 to Delphi 10.2

I’m impressed with all the improvements since Delphi XE6.

 

Advertisements

Add online activation to your application

This is the poor man’s solution to feature  online activation in your application.

Recipe ingredients:
Delphi
OnGuard Components (Free, Open Source). https://github.com/TurboPack/OnGuard-FMX
Post Component  (TMS TWebPost, Indy HTTP Post or similar components). https://www.tmssoftware.com/site/webpost.asp
PHP and MySQL Server.

Cooking Directions:
You can get OnGuard for Firemonkey here https://github.com/TurboPack/OnGuard-FMX instructional video https://www.youtube.com/watch?v=uyW_w_2ZC8M
TMS TWebPost https://www.tmssoftware.com/site/webpost.asp

On our form’s above our implementation section we add a global variable and the constant key that was generated by OnGuard as shown in the video.

//Code Snip

var
Form1: TForm1;
UNLOCKME : Boolean;
  const
CKey : TKey = ($E5,$SF,$94,$F4,$72,$C8,$A5,$D8,$8A,$FA,$6F,$7C,$AB,$FC,$E5,$8R);
procedure TForm1.FormActivate(Sender: TObject);
begin
if UNLOCKEME = false then
Begin
Form2.Show;
End;
end;

 

procedure TForm1.OgSerialNumberCode1Checked(Sender: TObject;
Status: TCodeStatus);
begin
case Status of
ogValidCode    : Begin
UNLOCKEME := TRUE;
End;
    ogInvalidCode  :  Begin
UNLOCKEME := FALSE;
End;
end;
end;
procedure TForm1.OgSerialNumberCode1GetCode(Sender: TObject; var Code: TCode);
var
S
begin
HexToBuffer(S, Code, SizeOf(Code));
end;

procedure TForm1.OgSerialNumberCode1GetKey(Sender: TObject; var Key: TKey);
begin
Key := CKey;
end;

 

Form2

procedure TForm2.Button1Click(Sender: TObject);
begin
if UNLOCKEME = false then
Begin
Form1.OgSerialNumberCode1.CheckCode(True);
if Form1.OgSerialNumberCode1.IsCodeValid then
ShowMessage(‘Invalid Key’);
end;
End;
if UNLOCKEME = True then
Form2.Close;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
wpi:twebpostitem;
s1, machine: String;
Key128: TKey128;
begin
webpost1.items.Clear;
if Edit1.Text <> ” then
begin
 with webpost1.items do
begin
wpi:=add;
wpi.name:=’email’;
wpi.value:= Edit1.Text;
end;
 if webpost1.execute then
begin
s1 := webpost1.PostResult;
if s1 <> ‘1’ then
Begin
if UNLOCKEME= false then
Begin
Form1.OgSerialNumberCode1.CheckCode(True);
if Form1.OgSerialNumberCode1.IsCodeValid then begin
Form2.Close;
ShowMessage(‘Activated ‘);
end Else  ShowMessage(‘Could not connect to server’);
Exit;
end;
End;
if UNLOCKEME = True then
Form2.Close;
end;
end;
end;
end;
Then you will need a PHP script  to post your request for the activation Key.

New Game Engine for FMX

I got a link to a new game engine for Firemonkey, it uses TImage to render the processed frames and scenes. Since Firemonkey suppose to take care of the low level stuff across platforms this aproach could abstract some of that to concentrate on the game action instead.

Get the code: https://github.com/dimsa/ShadowEngine

Watch the Demos:

SLoteria

Here is a simple slot machine game based on La Loteria Mexicana with a slot machine twist. A while back I was impressed how fast I could code a cards game with Delphi Firemonkey. Have done it before with XCode and Eclipse but for simple games Delphi is the quick and easy shortcut.

Check the video: https://youtu.be/C2C0WRBrjrs

Making SLoteria

 

 

Cocos2Dx meets Delphi

Cocos2Dx is a popular free cross platform game engine written in C++, searching the web I found a port of Cocos2dx 2.2 to Delphi. If it can be ported to Firemonkey it would be fantastic. It seems like this port works in Delphi for win32. I did test it in Delphi XE6, the 2 Demos worked as expected, at 60 fps.

Here is a screenshot of the HelloDelphi.Pas demo:
CocosDelphi

Repository for the Delphi XE5 source code is here:
https://github.com/HandymanPlus/delphi-cocos2dx