unit Texture; Interface Uses Objects, Graph, CRT; const Dx = 1;{Расстояние между клетками} Dy = 1; fMasshX :byte=0; fMasshY :byte=0; TextX :byte=25; TextY :byte=4; var FP : FillPatternType; fbkCol : byte; fMaxY, fMaxX : byte; fMinY, fMinX : byte; Type TString10 = string[10]; TCornerCol = object (TCollection) end; TDot = object (TObject) fNotDot : boolean; fDotCol : byte; fMaxDot : byte; fDotX, fDotY : byte; constructor Init(m:byte); procedure DrawDot; destructor Done;virtual; end; TScore = object (TObject) TST : TextSettingsType; fCount : byte; fName : TString10; fX, fY : byte; constructor Init(x, y: byte; st:TString10); procedure Show; procedure Clear; destructor Done;virtual; end; TLevel = object (TScore) end; TLife = object (TScore) procedure Show;virtual; procedure EraseOne; end; TCorner = object (TObject){Необходимо, чтобы хранить в коллекции} fX, fY : byte; fInDir : char; fOutDir : char; Constructor Init(X1, Y1:byte; InD, OutD : char); Destructor Done;virtual; end; PCorner = ^TCorner; TMainField = object (TObject) constructor Init(m1, n1, m2, n2:byte); procedure Zastavka; procedure DrawAll; procedure DrawOne(x, y: byte); destructor Done;virtual; end; Implementation var i:byte; function IntToStr(int1:integer):string; var st:string; begin str(int1, st); IntToStr:=st; end; constructor TDot.Init; begin fNotDot:=true; fDotCol:=Red; fMaxDot:=m; end; procedure TDot.DrawDot; begin SetFillPattern(FP, fDotCol); Bar(fDotX*fmasshX+dx, fDotY*fmasshY+dy, (fDotX+1)*fmasshX-dx, (fDotY+1)*fmasshY-dy); SetFillPattern(FP, fDotCol); end; destructor TDot.Done; begin Inherited Done; end; procedure TLife.Show; var i:byte; begin Clear; SetFillPattern(FP, Yellow); For i:= 1 to fCount do Bar(fX*fMasshX, (fY+i)*fMasshY+5*TST.CharSize, (fX+1)*fMasshX-DX, (fY+i+1)*fMasshY-2*DY+5*TST.CharSize); end; procedure TLife.EraseOne; begin SetFillPattern(FP, Blue); Bar(fX*fMasshX, (fY+fCount+1)*fMasshY+5*TST.CharSize, (fX+1)*fMasshX-DX, (fY+fCount+2)*fMasshY-2*DY+5*TST.CharSize); end; constructor TScore.Init; begin SetColor(White); GetTextSettings(TST); fCount:=1; fX:=x; fY:=y; fName:=st; OutTextXY(fX*fMasshX, fY*fMasshY, fName); end; procedure TScore.Clear; begin SetFillPattern(FP, Black); Bar(fX*fMasshX , (fY)*fMasshY+12*TST.CharSize, (fX+1)*fMasshX, (fY)*fMasshY+22*TST.CharSize); end; procedure TScore.Show; begin Clear; OutTextXY(fX*fMasshX, (fY)*fMasshY+10*TST.CharSize, IntToStr(fCount)); end; destructor TScore.Done; begin end; constructor TCorner.Init; begin fX:=X1; fY:=Y1; fInDir:=InD; fOutDir:=OutD; end; destructor TCorner.Done; begin Inherited Done; end; constructor TMainField.Init; begin fMasshX:=20; fMasshY:=20; fMaxX:=m2; fMaxY:=n2; fMinX:=m1; fMinY:=n1; fBkCol:=green; end; procedure TMainField.Zastavka; var i:byte; st:string; begin SetTextStyle(TriplexFont, HorizDir, 5); SetColor(Red); st:='The Yastrem loh:'; OutTextXY((GetMaxX shr 1)-(TextWidth(st) shr 1), 20, st); SetTextStyle(SansSerifFont, HorizDir, 8); SetColor(Blue); st:='The Kill him'; OutTextXY((GetMaxX shr 1)-(TextWidth(st) shr 1), 60, st); SetTextStyle(SmallFont, HorizDir, 7); SetColor(Green); i:=9; st:='Move Up - KeyBoard Up'; OutTextXY(20, GetMaxY-i*TextHeight(st), st); Dec(i); st:='Move Down - KeyBoard Down'; OutTextXY(20, GetMaxY-i*TextHeight(st), st); Dec(i); st:='Move Left - KeyBoard Left'; OutTextXY(20, GetMaxY-i*TextHeight(st), st); Dec(i); st:='Move Right - KeyBoard Right'; OutTextXY(20, GetMaxY-i*TextHeight(st), st); Dec(i); st:='Pause - KeyBoard P'; OutTextXY(20, GetMaxY-i*TextHeight(st), st); Dec(i); st:='Exit - KeyBoard Esc'; OutTextXY(20, GetMaxY-i*TextHeight(st), st); SetColor(LightGray); SetTextStyle(SmallFont, HorizDir, 6); st:='Press any key...'; OutTextXY((GetMaxX shr 1)-(TextWidth(st) shr 1), GetMaxY-2*TextHeight(st), st); ReadKey; ClearDevice; SetTextStyle(TriplexFont, HorizDir, 4); end; procedure TMainField.DrawOne; begin Bar(X*fmasshX+dx, Y*fmasshY+dy, (X+1)*fmasshX-dx, (Y+1)*fmasshY-dy); end; procedure TMainField.DrawAll; var i, j :byte; begin SetFillPattern(FP , fBkCol); For i:=0 to fMaxY-fMinY do For j:=0 to fMaxX-fMinX do DrawOne(fMinX+j,fMinY+i); end; destructor TMainField.done; begin Inherited Done; end; begin For i:=1 to 8 do FP[i]:=$FF; end.