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: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188:
| unit Main;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, pngimage, MPlayer, ComCtrls;
type Ship1ArrayType = Array [0..200] of TImage; TForm1 = class(TForm)
private public Timer1: TTimer; BGameStart: TButton; BClose: TButton; ScrollBar1: TScrollBar; MediaPlayer1: TMediaPlayer; Panel1: TPanel; Label1: TLabel; LRundenNr: TLabel; Label5: TLabel; LUnits: TLabel; PBGold: TProgressBar; Label3: TLabel; Label4: TLabel; LGold: TLabel; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure BGameStartClick(Sender: TObject); procedure CollisionAbfrage; procedure BCloseClick(Sender: TObject); procedure ScrollBar1Change(Sender: TObject); procedure Musik; procedure RundenBerechnung; procedure ObjekteInit; end;
var Ship1Typ : Ship1ArrayType; ShipProRunde:integer; count:integer; Form1: TForm1; stepX,stepY,Speed:integer; FBreite,FHoehe:integer; RandR,RandU:integer; ButtonKlick,RundeBerechnen,ShipVisi:boolean; PosX:integer; RundenNr,GoldVorrat,Gold,GoldMine:integer; LGoldCap:string;
const GoldProWave=50;
implementation
{$R *.dfm}
uses kampfsystem,user,AI,Buildings,VarInit;
procedure TForm1.RundenBerechnung; begin if (RundeBerechnen=true) then begin RundenNr:=RundenNr+1; RundeBerechnen:=false; RessProWave; LGold.Caption:=LGoldCap; end; end; procedure TForm1.Musik; begin Mediaplayer1.Close; Mediaplayer1.Filename := (ExtractFilePath(ParamStr(0))+'sound1.mp3'); Mediaplayer1.Open; Mediaplayer1.Play; end; procedure TForm1.ScrollBar1Change(Sender: TObject); begin Speed:=ScrollBar1.Position; end; procedure TForm1.CollisionAbfrage;var Ship1:integer;
begin for Ship1 := 0 to ShipProRunde -1 do begin if (Ship1Typ[Ship1].Top>=RandU) then begin Ship1Typ[Ship1].Top:=10; PosX:=0; RundeBerechnen:=true; end; end; end; procedure TForm1.ObjekteInit;var Ship1:integer;
begin
for Ship1 := 0 to ShipProRunde -1 do begin Ship1Typ[Ship1].Top:=stepX; Ship1Typ[Ship1].Left:=stepY; end; end; procedure TForm1.FormCreate(Sender: TObject);begin VariableInit; Ship1Init; timer1.Enabled:=false; Form1.Width:=FBreite; Form1.Height:=FHoehe; end;
procedure TForm1.BCloseClick(Sender: TObject); begin close; end; procedure TForm1.BGameStartClick(Sender: TObject); begin if ButtonKlick=true then begin timer1.Interval:=Speed; timer1.Enabled :=true; BGameStart.Caption:=('Stopp'); end;
if ButtonKlick=false then begin BGameStart.Caption:=('Spiel Starten'); Timer1.Enabled:=False; ButtonKlick:=true; end; end; procedure TForm1.Timer1Timer(Sender: TObject); var Ship1:integer; PosY:integer; begin if (ShipVisi=false) then begin for Ship1 := 0 to ShipProRunde -1 do begin Ship1Typ[Ship1].Visible:=true; ShipVisi:=true; end; end; PosY:=10; ButtonKlick:=false; timer1.Interval:=Speed; timer1.Enabled:=true; for Ship1 := 0 to ShipProRunde -1 do begin Ship1Typ[Ship1].Top:=Ship1Typ[Ship1].Top+stepX; Ship1Typ[Ship1].Left:=PosY; PosY:=PosY+50; if (PosY>=600) then begin PosY:=0; PosX:=PosX+1; end; end; CollisionAbfrage; RundenBerechnung; LRundenNr.Caption:=inttostr(RundenNr); end; end. |