Skip to content

Commit d7b2fe4

Browse files
committed
Initial commit
Initial commit
1 parent 8ea9884 commit d7b2fe4

File tree

7 files changed

+5349
-0
lines changed

7 files changed

+5349
-0
lines changed

Delphier.dpr

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
program Delphier;
2+
3+
uses
4+
System.StartUpCopy,
5+
FMX.Forms,
6+
FMX.Types,
7+
uMain in 'uMain.pas' {FormMain},
8+
uGame in 'uGame.pas',
9+
uUtils in 'uUtils.pas';
10+
11+
{$R *.res}
12+
13+
begin
14+
{$IFDEF MACOS}
15+
GlobalUseMetal := True;
16+
{$ENDIF}
17+
Application.Initialize;
18+
Application.FormFactor.Orientations := [TFormOrientation.Landscape];
19+
Application.CreateForm(TFormMain, FormMain);
20+
Application.Run;
21+
end.
22+

Delphier.dproj

Lines changed: 3476 additions & 0 deletions
Large diffs are not rendered by default.

Delphier.res

109 KB
Binary file not shown.

uGame.pas

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
unit uGame;
2+
3+
interface
4+
5+
uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
6+
FMX.Objects, FMX.Layouts, FMX.Graphics;
7+
8+
type
9+
TDirection = (droite, gauche);
10+
TAnimationJoueur = (idleDroite, idleGauche, courtDroite, courtGauche);
11+
12+
TScrolling = class(TLayout)
13+
private
14+
fRectangle: TRectangle;
15+
fVitesse: single;
16+
public
17+
constructor Create(AOwner: TComponent); override;
18+
property Rectangle: TRectangle read fRectangle write fRectangle;
19+
property Vitesse: single read fVitesse write fVitesse;
20+
end;
21+
22+
TPlateformeInfos = record
23+
public
24+
animation, image: string;
25+
end;
26+
27+
TEnnemi = record
28+
public
29+
image1, image2, deplacement: string;
30+
count: integer;
31+
duration: single;
32+
end;
33+
34+
TBonus = record
35+
public
36+
image: string;
37+
count: integer;
38+
duration: single;
39+
end;
40+
41+
TCollision = record
42+
public
43+
enCollision : boolean;
44+
objet : TImage;
45+
end;
46+
47+
function gererCollisions(position : TPoint; joueur : TImage; unRectangle : TRectangle; detruireObjetTouche: boolean): TCollision;
48+
function gererCollisionsPlateformes(positionJoueur : TPoint; joueur : TImage; unRectangle : TRectangle): TCollision;
49+
function gererCollisionsJoueurAvecUnePlateforme(positionJoueur : TPoint; joueur, plateforme : TImage): boolean;
50+
51+
const
52+
vitesseXMax = 3; // Vitesse de déplacement du joueur
53+
puissanceSaut = 10; // Force du saut
54+
formWidth = 480; // 30 tiles de 16 pixels
55+
formHeight = 272; // 17 tiles de 16 pixles
56+
57+
implementation
58+
59+
constructor TScrolling.create(AOwner: TComponent);
60+
begin
61+
inherited;
62+
fRectangle := TRectangle.create(nil);
63+
fRectangle.Parent := self;
64+
fRectangle.HitTest := false;
65+
fRectangle.Fill.Kind := TBrushKind.Bitmap;
66+
fRectangle.Fill.Bitmap.WrapMode := TWrapMode.Tile;
67+
fRectangle.stroke.Dash := TStrokeDash.Solid;
68+
fRectangle.stroke.Color := TAlphaColorRec.Null;
69+
fRectangle.stroke.Kind := TBrushKind.Solid;
70+
fRectangle.stroke.Thickness := 1;
71+
fVitesse := 0;
72+
end;
73+
74+
function gererCollisions(position : TPoint; joueur : TImage; unRectangle : TRectangle; detruireObjetTouche: boolean):TCollision;
75+
begin
76+
var enCollision := false;
77+
for var recChild in unRectangle.Children do begin
78+
var unEnfant : TImage := recChild as TImage;
79+
if (position.X > unEnfant.Position.X) and (position.X < unEnfant.Position.X + unEnfant.Width) and
80+
(position.y + joueur.Height > unEnfant.Position.Y) and (position.y < unEnfant.Position.Y + unEnfant.Height) then begin
81+
enCollision := true;
82+
result.objet := unEnfant;
83+
if detruireObjetTouche then unEnfant.free;
84+
break;
85+
end;
86+
end;
87+
result.enCollision := enCollision;
88+
end;
89+
90+
function gererCollisionsPlateformes(positionJoueur : TPoint; joueur: TImage; unRectangle : TRectangle):TCollision;
91+
begin
92+
result.enCollision := false;
93+
for var recChild in unRectangle.Children do begin
94+
var unEnfant : TImage := recChild as TImage;
95+
if gererCollisionsJoueurAvecUnePlateforme(positionJoueur, joueur, unEnfant) then begin
96+
result.enCollision := true;
97+
result.objet := unEnfant;
98+
break;
99+
end;
100+
end;
101+
end;
102+
103+
function gererCollisionsJoueurAvecUnePlateforme(positionJoueur : TPoint; joueur, plateforme : TImage): boolean;
104+
begin
105+
Result := ((positionJoueur.X + joueur.Width * 0.75) > plateforme.Position.x) and
106+
((positionJoueur.X + joueur.Width * 0.25)< plateforme.Position.X + plateforme.width) and
107+
(positionJoueur.Y + joueur.Height > plateforme.Position.Y) and
108+
(positionJoueur.Y < plateforme.Position.Y) and
109+
(plateforme.Opacity > 0.3);
110+
end;
111+
112+
end.

0 commit comments

Comments
 (0)