Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
- StdCtrls, glass;
- type
- { TForm1 }
- TForm1 = class(TForm)
- background: TImage;
- hard: TRadioButton;
- difficultylabel: TLabel;
- normal: TRadioButton;
- easy: TRadioButton;
- Reset: TButton;
- HyperPog: TImage;
- d1: TImage;
- d2: TImage;
- death1: TImage;
- death2: TImage;
- score: TLabel;
- One: TImage;
- hop: TTimer;
- hopdelay: TTimer;
- highscore: TLabel;
- td: TTimer;
- death: TTimer;
- difficulty: TTimer;
- Timer1: TTimer;
- tscore: TTimer;
- Two: TImage;
- Three: TImage;
- resume: TButton;
- pause: TButton;
- hero1: TImage;
- hero2: TImage;
- hero3: TImage;
- hero4: TImage;
- start: TButton;
- thero1: TTimer;
- thero2: TTimer;
- thero3: TTimer;
- thero4: TTimer;
- Countdown: TTimer;
- procedure deathTimer(Sender: TObject);
- procedure difficultyTimer(Sender: TObject);
- procedure FormActivate(Sender: TObject);
- procedure FormKeyUp(Sender: TObject);
- procedure hopdelayTimer(Sender: TObject);
- procedure hopTimer(Sender: TObject);
- procedure pauseClick(Sender: TObject);
- procedure ResetClick(Sender: TObject);
- procedure resumeClick(Sender: TObject);
- procedure startClick(Sender: TObject);
- procedure tdTimer(Sender: TObject);
- procedure thero1Timer(Sender: TObject);
- procedure thero2Timer(Sender: TObject);
- procedure thero3Timer(Sender: TObject);
- procedure thero4Timer(Sender: TObject);
- procedure CountdownTimer(Sender: TObject);
- procedure tscoreTimer(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- p:boolean=true; //pause status
- hopd:boolean=false; //hop delay status
- animation:integer; //hero run animation status
- countd:integer; //countdown status
- danger:integer; //generating dangerous status
- distance:integer; //Coordinates generation coordinate
- sc:integer; //score
- hsc:integer; //highscore
- dif:integer; //difficulty
- ddif:integer; //difficulty distance
- rdif:integer; //coefficient difficulty
- implementation
- {$R *.lfm}
- { TForm1 }
- {==============================================================================}
- {Technical}
- procedure TForm1.FormActivate(Sender: TObject); //windows aero
- var tmpMargins: TMargins;
- begin
- { If all margins are -1 the whole form will be aero glass}
- tmpMargins.cxLeftWidth := -1;
- tmpMargins.cxRightWidth := -1;
- tmpMargins.cyBottomHeight := -1;
- tmpMargins.cyTopHeight := -1;
- { FormName ; Margins ; TransparentColor }
- GlassForm(Self, tmpMargins, clFuchsia);
- end;
- procedure TForm1.startClick(Sender: TObject); //start
- begin
- start.Visible:=False;
- countd:=0;
- score.Caption:='Score: 0';
- highscore.Caption:='High score: 0';
- score.Visible:=True;
- highscore.Visible:=True;
- pause.Visible:=True;
- countdown.Enabled:=True;
- end;
- procedure TForm1.ResetClick(Sender: TObject); //reset
- begin
- countd:=0;
- countdown.Enabled:=True;
- death1.Visible:=False;
- death2.Visible:=False;
- pause.Enabled:=False;
- pause.Visible:=True;
- reset.Visible:=False;
- score.Caption:='Score: 0';
- end;
- procedure TForm1.pauseClick(Sender: TObject); //pause
- begin
- tscore.Enabled:=False;
- td.Enabled:=False;
- p:=true;
- pause.Enabled:=False;
- resume.Enabled:=True;
- resume.Visible:=True;
- animation:=0;
- pause.Visible:=False;
- end;
- procedure TForm1.resumeClick(Sender: TObject); //resume
- begin
- resume.Enabled:=False;
- pause.Visible:=True;
- countd:=0;
- countdown.Enabled:=True;
- resume.Visible:=False;
- end;
- procedure TForm1.CountdownTimer(Sender: TObject); //countdown
- begin
- countd:=countd+1;
- if countd=1
- then begin
- three.Visible:=True;
- end;
- if countd=2
- then begin
- three.Visible:=False;
- two.Visible:=True;
- end;
- if countd=3
- then begin
- two.Visible:=False;
- one.Visible:=True;
- end;
- if countd=4
- then begin
- one.Visible:=False;
- HyperPog.Visible:=True;
- end;
- if countd=5
- then begin
- dif:=10;
- rdif:=5;
- sc:=0;
- HyperPog.Visible:=False;
- animation:=1;
- hero1.Visible:=True;
- thero1.Enabled:=True;
- d1.Visible:=True;
- td.Enabled:=True;
- pause.Enabled:=True;
- p:=false;
- easy.Visible:=False;
- normal.Visible:=False;
- hard.Visible:=False;
- difficultylabel.Visible:=False;
- hop.Enabled:=True;
- death.Enabled:=True;
- tscore.Enabled:=True;
- end;
- end;
- procedure TForm1.tscoreTimer(Sender: TObject); //score
- begin
- if score.Visible=True
- Then begin
- sc:=sc+1;
- score.Caption:='Score: '+IntToStr(sc);
- end;
- end;
- {==============================================================================}
- {Animation}
- procedure TForm1.thero1Timer(Sender: TObject); //hero1
- begin
- if animation=1
- then begin
- animation:=2;
- hero2.Visible:=True;
- thero2.Enabled:=True;
- hero1.Visible:=False;
- thero1.Enabled:=False;
- end;
- end;
- procedure TForm1.thero2Timer(Sender: TObject); //hero2
- begin
- if animation=2
- then begin
- animation:=3;
- hero3.Visible:=True;
- thero3.Enabled:=True;
- hero2.Visible:=False;
- thero2.Enabled:=False;
- end;
- end;
- procedure TForm1.thero3Timer(Sender: TObject); //hero3
- begin
- if animation=3
- then begin
- animation:=4;
- hero4.Visible:=True;
- thero4.Enabled:=True;
- hero3.Visible:=False;
- thero3.Enabled:=False;
- end;
- end;
- procedure TForm1.thero4Timer(Sender: TObject); //hero4
- begin
- if animation=4
- then begin
- animation:=1;
- hero1.Visible:=True;
- thero1.Enabled:=True;
- hero4.Visible:=False;
- thero4.Enabled:=False;
- end;
- end;
- procedure TForm1.FormKeyUp(Sender: TObject); //jump start
- begin
- if p=false
- then begin
- if hopd=false
- then begin
- if hero1.Top=232
- then begin
- hop.Enabled:=True;
- d1.Left:=d1.Left-70;
- d2.Left:=d2.Left-70;
- hero1.Top:=hero1.Top-100;
- hero2.Top:=hero2.Top-100;
- hero3.Top:=hero3.Top-100;
- hero4.Top:=hero4.Top-100;
- end;
- end;
- end;
- end;
- procedure TForm1.hopTimer(Sender: TObject); //jump done
- begin
- if hero1.Top<232
- then begin
- hopdelay.Enabled:=True;
- hero1.Top:=232;
- hero2.Top:=216;
- hero3.Top:=216;
- hero4.Top:=232;
- hop.Enabled:=False;
- hopd:=True;
- end;
- end;
- procedure TForm1.hopdelayTimer(Sender: TObject); //jump delay
- begin
- hopd:=False;
- hopdelay.Enabled:=False;
- end;
- {==============================================================================}
- {Gameplay}
- procedure TForm1.tdTimer(Sender: TObject); //dangerous
- begin
- randomize;
- danger:=random(2);
- distance:=random(450);
- if d1.Left<-150
- then begin
- if danger=0
- then begin
- d2.Visible:=False;
- d2.Left:=528;
- d1.Visible:=True;
- d1.Left:=800-distance;
- end;
- end;
- if d2.Left<-150
- then begin
- if danger=1
- then begin
- d1.Visible:=False;
- d1.Left:=528;
- d2.Visible:=True;
- d2.Left:=800-distance;
- end;
- end;
- d1.Left:=d1.Left-ddif;
- d2.Left:=d2.Left-ddif;
- end;
- procedure TForm1.difficultyTimer(Sender: TObject); //difficulty
- begin
- if easy.Checked=True
- then begin
- if sc=rdif
- then begin
- rdif:=rdif+5;
- ddif:=ddif+5;
- end;
- end;
- if normal.Checked=True
- then begin
- if sc=rdif
- then begin
- rdif:=rdif+10;
- ddif:=ddif+10;
- end;
- end;
- if hard.Checked=True
- then begin
- if sc=rdif
- then begin
- rdif:=rdif+15;
- ddif:=ddif+15;
- end;
- end;
- end;
- procedure TForm1.deathTimer(Sender: TObject); //death
- begin
- if hero1.Top=232
- then begin
- if d1.Left<180
- then begin
- if d1.Left>40
- then begin
- hop.Enabled:=False;
- countdown.Enabled:=False;
- td.Enabled:=False;
- pause.Visible:=False;
- animation:=0;
- hero1.Visible:=False;
- hero2.Visible:=False;
- hero3.Visible:=False;
- hero4.Visible:=False;
- tscore.Enabled:=False;
- score.Caption:='Score: 0';
- reset.Visible:=True;
- pause.Visible:=False;
- d1.Left:=528;
- d2.Left:=528;
- if hsc<sc
- then begin
- highscore.Caption:='High Score: ' + IntToStr(sc);
- hsc:=sc;
- end;
- if d1.Visible=True
- then begin
- death1.Visible:=True;
- reset.Height:=74;
- reset.Width:=304;
- reset.Top:=272;
- reset.Left:=224;
- end;
- if d2.Visible=True
- then begin
- death2.Visible:=True;
- reset.Height:=48;
- reset.Width:=150;
- reset.Top:=400;
- reset.Left:=325;
- end;
- d1.Visible:=False;
- d2.Visible:=False;
- death.Enabled:=False;
- end;
- end;
- end;
- end;
- {==============================================================================}
- {???}
- //procedure
- {==============================================================================}
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement