-
Notifications
You must be signed in to change notification settings - Fork 29
/
mainUnit.pas
104 lines (85 loc) · 2.4 KB
/
mainUnit.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
unit mainUnit;
interface
uses
System.Types, System.UITypes, FMX.Forms, FMX.Objects, FMX.Controls,
System.Classes, FMX.Types, FMX.Dialogs, FMX.StdCtrls,
FMX.Advertising,
uEasyDevice, uDemoGame, uBannerPanel, FMX.Layouts, FMX.Controls.Presentation, FMX.Edit;
type
TmainForm = class(TForm)
mainImage: TImage;
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
procedure FormResize(Sender: TObject);
procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
{ procedure mainImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single); }
private
Game: TDemoGame;
{$IFDEF RELEASE}
BannerPanel: TBannerPanel;
{$ENDIF}
{ Private declarations }
public
{ Public declarations }
end;
var
mainForm: TmainForm;
implementation
{$R *.fmx}
procedure TmainForm.FormCreate(Sender: TObject);
begin
{$DEFINE DEBUG}
Game := TDemoGame.Create;
Game.Image := mainImage;
{$IFDEF ANDROID}
BorderStyle := TFmxFormBorderStyle.None;
{$ENDIF}
{$IFDEF RELEASE}
BannerPanel := TBannerPanel.Create(mainForm);
{$I private/admob.inc} // Remove for your project.
BannerPanel.Prepare;
Game.Banners := BannerPanel;
{$ENDIF}
Game.Prepare;
Game.Start;
end;
procedure TmainForm.FormKeyDown(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
begin
if KeyChar = #32 then
Game.DrawFigures := not Game.DrawFigures;
if ReturnPressed(Key) then
begin
{$IFDEF RELEASE}
if BannerPanel.Visible then
begin
BannerPanel.Visible := False;
Exit;
end;
{$ENDIF}
case Game.GameStatus of
gsMenu2: Game.GameStatus := gsMenu1;
gsMenu3: Game.GameStatus := gsMenu2;
gsStatistics: Game.GameStatus := gsMenu1;
gsAbout: Game.GameStatus := gsMenu1;
gsStoryMode, gsRelaxMode, gsSurvivalMode, gsGameOver, gsComix1, gsComix2, gsComix3, gsNextLevel, gsRetryLevel: Game.GameStatus := gsMenu1;
end;
end;
end;
procedure TmainForm.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if ReturnPressed(Key) then
Key := 0;
end;
procedure TmainForm.FormResize(Sender: TObject);
begin
Game.Resize(Round(mainImage.Width), Round(mainImage.Height));
{$IFDEF RELEASE}
BannerPanel.Resize;
{$ENDIF}
end;
end.