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:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) PaintBox1: TPaintBox; Timer1: TTimer; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; Edit5: TEdit; Button1: TButton; Timer2: TTimer; Timer3: TTimer; Button2: TButton; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormKeyPress(Sender: TObject; var Key: Char); procedure Timer3Timer(Sender: TObject); procedure Button2Click(Sender: TObject); private public end;
var Form1: TForm1; ASpielfeld: array of array of integer; Xposition,YPosition, AXPosition, AYPosition:integer; implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin
setlength(ASpielfeld, 17); SetLength(ASpielfeld[0], 13); SetLength(ASpielfeld[1], 13); SetLength(ASpielfeld[2], 13); SetLength(ASpielfeld[3], 13); SetLength(ASpielfeld[4], 13); SetLength(ASpielfeld[5], 13); SetLength(ASpielfeld[6], 13); SetLength(ASpielfeld[7], 13); SetLength(ASpielfeld[8], 13); SetLength(ASpielfeld[9], 13); SetLength(ASpielfeld[10], 13); SetLength(ASpielfeld[11], 13); SetLength(ASpielfeld[12], 13); SetLength(ASpielfeld[13], 13); SetLength(ASpielfeld[14], 13); SetLength(ASpielfeld[15], 13); SetLength(ASpielfeld[16], 13); AXposition:=6; Xposition:=150;
end;
procedure TForm1.Timer1Timer(Sender: TObject); begin Yposition:=Yposition+25; AYPosition:=AYPosition+1; paintbox1.repaint; edit1.Text:=inttostr(Yposition); edit2.Text:=inttostr(AYPosition);
if AYPosition=16 then begin ASpielfeld[AYposition,AXPosition]:=1; AXposition:=6; Xposition:=150; YPosition:=-25; AYPosition:=-1; end;
if ASpielfeld[AYPosition+1,Axposition]=1 then begin ASpielfeld[AYposition,AXPosition]:=1; AXposition:=6; Xposition:=150; YPosition:=-25; AYPosition:=-1; end; paintbox1.Canvas.Rectangle(Xposition,YPosition,Xposition+25,YPosition+25);
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char); begin case key of char('d'): if (xposition=300) or (ASpielfeld[AYPosition,Axposition+1]=1) or (YPosition=16) then else begin xposition:=xposition+25; AXPosition:=AXPosition+1 end; char('a'): if (xposition=0) or (ASpielfeld[AYPosition,Axposition-1]=1) or (YPosition=16) then else begin xposition:=xposition-25; AXPosition:=AXPosition-1; end; end;
paintbox1.Refresh;
edit3.Text:=inttostr(xposition);
end;
procedure TForm1.Button2Click(Sender: TObject); begin edit5.Text:=inttostr(ASpielfeld[16,1]); end;
procedure TForm1.Timer3Timer(Sender: TObject); begin edit4.Text:=inttostr(AXPosition); end;
end. |