Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 8.64 KB | None | 0 0
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
  9.   StdCtrls, glass;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     background: TImage;
  17.     hard: TRadioButton;
  18.     difficultylabel: TLabel;
  19.     normal: TRadioButton;
  20.     easy: TRadioButton;
  21.     Reset: TButton;
  22.     HyperPog: TImage;
  23.     d1: TImage;
  24.     d2: TImage;
  25.     death1: TImage;
  26.     death2: TImage;
  27.     score: TLabel;
  28.     One: TImage;
  29.     hop: TTimer;
  30.     hopdelay: TTimer;
  31.     highscore: TLabel;
  32.     td: TTimer;
  33.     death: TTimer;
  34.     difficulty: TTimer;
  35.     Timer1: TTimer;
  36.     tscore: TTimer;
  37.     Two: TImage;
  38.     Three: TImage;
  39.     resume: TButton;
  40.     pause: TButton;
  41.     hero1: TImage;
  42.     hero2: TImage;
  43.     hero3: TImage;
  44.     hero4: TImage;
  45.     start: TButton;
  46.     thero1: TTimer;
  47.     thero2: TTimer;
  48.     thero3: TTimer;
  49.     thero4: TTimer;
  50.     Countdown: TTimer;
  51.     procedure deathTimer(Sender: TObject);
  52.     procedure difficultyTimer(Sender: TObject);
  53.     procedure FormActivate(Sender: TObject);
  54.     procedure FormKeyUp(Sender: TObject);
  55.     procedure hopdelayTimer(Sender: TObject);
  56.     procedure hopTimer(Sender: TObject);
  57.     procedure pauseClick(Sender: TObject);
  58.     procedure ResetClick(Sender: TObject);
  59.     procedure resumeClick(Sender: TObject);
  60.     procedure startClick(Sender: TObject);
  61.     procedure tdTimer(Sender: TObject);
  62.     procedure thero1Timer(Sender: TObject);
  63.     procedure thero2Timer(Sender: TObject);
  64.     procedure thero3Timer(Sender: TObject);
  65.     procedure thero4Timer(Sender: TObject);
  66.     procedure CountdownTimer(Sender: TObject);
  67.     procedure tscoreTimer(Sender: TObject);
  68.   private
  69.     { private declarations }
  70.   public
  71.     { public declarations }
  72.   end;
  73.  
  74. var
  75.   Form1: TForm1;
  76.   p:boolean=true; //pause status
  77.   hopd:boolean=false; //hop delay status
  78.   animation:integer; //hero run animation status
  79.   countd:integer; //countdown status
  80.   danger:integer; //generating dangerous status
  81.   distance:integer; //Coordinates generation coordinate
  82.   sc:integer; //score
  83.   hsc:integer; //highscore
  84.   dif:integer; //difficulty
  85.   ddif:integer; //difficulty distance
  86.   rdif:integer; //coefficient difficulty
  87.  
  88. implementation
  89.  
  90. {$R *.lfm}
  91.  
  92. { TForm1 }
  93.  
  94. {==============================================================================}
  95.  
  96. {Technical}
  97. procedure TForm1.FormActivate(Sender: TObject); //windows aero
  98. var tmpMargins: TMargins;
  99. begin
  100.   { If all margins are -1 the whole form will be aero glass}
  101.   tmpMargins.cxLeftWidth    := -1;
  102.   tmpMargins.cxRightWidth   := -1;
  103.   tmpMargins.cyBottomHeight := -1;
  104.   tmpMargins.cyTopHeight    := -1;
  105.   { FormName ; Margins ; TransparentColor }
  106.   GlassForm(Self, tmpMargins, clFuchsia);
  107. end;
  108.  
  109. procedure TForm1.startClick(Sender: TObject); //start
  110. begin
  111.   start.Visible:=False;
  112.   countd:=0;
  113.   score.Caption:='Score: 0';
  114.   highscore.Caption:='High score: 0';
  115.   score.Visible:=True;
  116.   highscore.Visible:=True;
  117.   pause.Visible:=True;
  118.   countdown.Enabled:=True;
  119. end;
  120. procedure TForm1.ResetClick(Sender: TObject); //reset
  121. begin
  122.  countd:=0;
  123.  countdown.Enabled:=True;
  124.  death1.Visible:=False;
  125.  death2.Visible:=False;
  126.  pause.Enabled:=False;
  127.  pause.Visible:=True;
  128.  reset.Visible:=False;
  129.  score.Caption:='Score: 0';
  130. end;
  131. procedure TForm1.pauseClick(Sender: TObject); //pause
  132. begin
  133.  tscore.Enabled:=False;
  134.  td.Enabled:=False;
  135.  p:=true;
  136.  pause.Enabled:=False;
  137.  resume.Enabled:=True;
  138.  resume.Visible:=True;
  139.  animation:=0;
  140.  pause.Visible:=False;
  141. end;
  142. procedure TForm1.resumeClick(Sender: TObject); //resume
  143. begin
  144.  resume.Enabled:=False;
  145.  pause.Visible:=True;
  146.  countd:=0;
  147.  countdown.Enabled:=True;
  148.  resume.Visible:=False;
  149. end;
  150.  
  151. procedure TForm1.CountdownTimer(Sender: TObject); //countdown
  152. begin
  153.  countd:=countd+1;
  154.  if countd=1
  155.  then begin
  156.   three.Visible:=True;
  157.  end;
  158.  if countd=2
  159.  then begin
  160.   three.Visible:=False;
  161.   two.Visible:=True;
  162.  end;
  163.  if countd=3
  164.  then begin
  165.   two.Visible:=False;
  166.   one.Visible:=True;
  167.  end;
  168.  if countd=4
  169.  then begin
  170.   one.Visible:=False;
  171.   HyperPog.Visible:=True;
  172.  end;
  173.  if countd=5
  174.  then begin
  175.   dif:=10;
  176.   rdif:=5;
  177.   sc:=0;
  178.   HyperPog.Visible:=False;
  179.   animation:=1;
  180.   hero1.Visible:=True;
  181.   thero1.Enabled:=True;
  182.   d1.Visible:=True;
  183.   td.Enabled:=True;
  184.   pause.Enabled:=True;
  185.   p:=false;
  186.   easy.Visible:=False;
  187.   normal.Visible:=False;
  188.   hard.Visible:=False;
  189.   difficultylabel.Visible:=False;
  190.   hop.Enabled:=True;
  191.   death.Enabled:=True;
  192.   tscore.Enabled:=True;
  193.  end;
  194. end;
  195. procedure TForm1.tscoreTimer(Sender: TObject); //score
  196. begin
  197.  if score.Visible=True
  198.  Then begin
  199.   sc:=sc+1;
  200.   score.Caption:='Score: '+IntToStr(sc);
  201.  end;
  202. end;
  203.  
  204. {==============================================================================}
  205.  
  206. {Animation}
  207. procedure TForm1.thero1Timer(Sender: TObject); //hero1
  208. begin
  209.  if animation=1
  210.  then begin
  211.   animation:=2;
  212.   hero2.Visible:=True;
  213.   thero2.Enabled:=True;
  214.   hero1.Visible:=False;
  215.   thero1.Enabled:=False;
  216.  end;
  217. end;
  218. procedure TForm1.thero2Timer(Sender: TObject); //hero2
  219. begin
  220.  if animation=2
  221.  then begin
  222.   animation:=3;
  223.   hero3.Visible:=True;
  224.   thero3.Enabled:=True;
  225.   hero2.Visible:=False;
  226.   thero2.Enabled:=False;
  227.  end;
  228. end;
  229. procedure TForm1.thero3Timer(Sender: TObject); //hero3
  230. begin
  231.  if animation=3
  232.  then begin
  233.   animation:=4;
  234.   hero4.Visible:=True;
  235.   thero4.Enabled:=True;
  236.   hero3.Visible:=False;
  237.   thero3.Enabled:=False;
  238.  end;
  239. end;
  240. procedure TForm1.thero4Timer(Sender: TObject); //hero4
  241. begin
  242.  if animation=4
  243.  then begin
  244.   animation:=1;
  245.   hero1.Visible:=True;
  246.   thero1.Enabled:=True;
  247.   hero4.Visible:=False;
  248.   thero4.Enabled:=False;
  249.  end;
  250. end;
  251.  
  252. procedure TForm1.FormKeyUp(Sender: TObject); //jump start
  253. begin
  254.  if p=false
  255.  then begin
  256.   if hopd=false
  257.   then begin
  258.     if hero1.Top=232
  259.     then begin
  260.      hop.Enabled:=True;
  261.      d1.Left:=d1.Left-70;
  262.      d2.Left:=d2.Left-70;
  263.      hero1.Top:=hero1.Top-100;
  264.      hero2.Top:=hero2.Top-100;
  265.      hero3.Top:=hero3.Top-100;
  266.      hero4.Top:=hero4.Top-100;
  267.    end;
  268.   end;
  269.  end;
  270. end;
  271. procedure TForm1.hopTimer(Sender: TObject); //jump done
  272. begin
  273.  if hero1.Top<232
  274.  then begin
  275.   hopdelay.Enabled:=True;
  276.   hero1.Top:=232;
  277.   hero2.Top:=216;
  278.   hero3.Top:=216;
  279.   hero4.Top:=232;
  280.   hop.Enabled:=False;
  281.   hopd:=True;
  282.  end;
  283. end;
  284. procedure TForm1.hopdelayTimer(Sender: TObject); //jump delay
  285. begin
  286.  hopd:=False;
  287.  hopdelay.Enabled:=False;
  288. end;
  289.  
  290. {==============================================================================}
  291.  
  292. {Gameplay}
  293. procedure TForm1.tdTimer(Sender: TObject); //dangerous
  294. begin
  295.  randomize;
  296.  danger:=random(2);
  297.  distance:=random(450);
  298.  if d1.Left<-150
  299.  then begin
  300.   if danger=0
  301.   then begin
  302.    d2.Visible:=False;
  303.    d2.Left:=528;
  304.    d1.Visible:=True;
  305.    d1.Left:=800-distance;
  306.   end;
  307.  end;
  308.  if d2.Left<-150
  309.  then begin
  310.   if danger=1
  311.   then begin
  312.    d1.Visible:=False;
  313.    d1.Left:=528;
  314.    d2.Visible:=True;
  315.    d2.Left:=800-distance;
  316.   end;
  317.  end;
  318.  d1.Left:=d1.Left-ddif;
  319.  d2.Left:=d2.Left-ddif;
  320. end;
  321. procedure TForm1.difficultyTimer(Sender: TObject); //difficulty
  322. begin
  323.  if easy.Checked=True
  324.  then begin
  325.   if sc=rdif
  326.   then begin
  327.    rdif:=rdif+5;
  328.    ddif:=ddif+5;
  329.   end;
  330.  end;
  331.  if normal.Checked=True
  332.  then begin
  333.   if sc=rdif
  334.   then begin
  335.    rdif:=rdif+10;
  336.    ddif:=ddif+10;
  337.   end;
  338.  end;
  339.  if hard.Checked=True
  340.  then begin
  341.   if sc=rdif
  342.   then begin
  343.    rdif:=rdif+15;
  344.    ddif:=ddif+15;
  345.   end;
  346.  end;
  347. end;
  348. procedure TForm1.deathTimer(Sender: TObject); //death
  349. begin
  350.  if hero1.Top=232
  351.  then begin
  352.   if d1.Left<180
  353.   then begin
  354.    if d1.Left>40
  355.    then begin
  356.     hop.Enabled:=False;
  357.     countdown.Enabled:=False;
  358.     td.Enabled:=False;
  359.     pause.Visible:=False;
  360.     animation:=0;
  361.     hero1.Visible:=False;
  362.     hero2.Visible:=False;
  363.     hero3.Visible:=False;
  364.     hero4.Visible:=False;
  365.     tscore.Enabled:=False;
  366.     score.Caption:='Score: 0';
  367.     reset.Visible:=True;
  368.     pause.Visible:=False;
  369.     d1.Left:=528;
  370.     d2.Left:=528;
  371.     if hsc<sc
  372.     then begin
  373.      highscore.Caption:='High Score: ' + IntToStr(sc);
  374.      hsc:=sc;
  375.     end;
  376.     if d1.Visible=True
  377.     then begin
  378.      death1.Visible:=True;
  379.      reset.Height:=74;
  380.      reset.Width:=304;
  381.      reset.Top:=272;
  382.      reset.Left:=224;
  383.     end;
  384.     if d2.Visible=True
  385.     then begin
  386.      death2.Visible:=True;
  387.      reset.Height:=48;
  388.      reset.Width:=150;
  389.      reset.Top:=400;
  390.      reset.Left:=325;
  391.     end;
  392.     d1.Visible:=False;
  393.     d2.Visible:=False;
  394.     death.Enabled:=False;
  395.    end;
  396.   end;
  397.  end;
  398. end;
  399.  
  400. {==============================================================================}
  401.  
  402. {???}
  403. //procedure
  404.  
  405. {==============================================================================}
  406.  
  407. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement