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
| {$G+}
uses Dos, App, Objects, Views, Drivers, Dialogs, MsgBox, Validate, Menus, StdDlg;
type PDamier = ^TDamier;
TDamier = object(TView)
public
constructor Init(var Bounds: TRect);
procedure Draw; virtual;
function GetPalette: PPalette; virtual;
destructor Done; virtual;
end;
type TMyApp = object(TApplication)
private
Damier: PDamier;
public
constructor Init;
procedure InitMenuBar; virtual;
procedure InitStatusLine; virtual;
procedure InitDesktop; virtual;
function GetPalette: PPalette; virtual;
destructor Done; virtual;
end;
const CAppPalette = #$78#$70#$78#$74#$20#$74#$78#$73#$7F#$7A +
#$31#$31#$1E#$71#$00#$2F#$3F#$3A#$13#$13 +
#$3E#$21#$00#$70#$7F#$13#$78#$74#$70#$7F +
#$00#$70#$7F#$7A#$13#$13#$70#$70#$7F#$7E +
#$20#$2B#$2F#$78#$2E#$70#$30#$3F#$3E#$1F +
#$2F#$1A#$20#$72#$31#$31#$30#$2F#$3E#$31 +
#$13#$00#$00#$07#$70;
const CDamier = CBackGround + #64#65;
var MyApp: TMyApp;
constructor TDamier.Init(var Bounds: TRect);
begin
if not inherited Init(Bounds) then Fail;
end;
procedure TDamier.Draw;
var X, Y, I: Integer;
begin
inherited Draw;
for Y := 0 to 8 do
for X := 0 to 8 do
begin
for I := 0 to 4 do
begin
if (odd(X) xor odd(Y) = true) then
WriteChar(X * 5, Y * 5 + I, ' ', 2, 5)
else
WriteChar(X * 5, Y * 5 + I, ' ', 3, 5);
end;
if (odd(X) xor odd(Y) = true) then
WriteChar(X * 5 + 2, Y * 5 + 2, '*', 2, 1)
else
WriteChar(X * 5 + 2, Y * 5 + 2, '*', 3, 1);
end;
end;
function TDamier.GetPalette: PPalette;
const P: String[Length(CAppPalette)] = CDamier;
begin
GetPalette := @P;
end;
destructor TDamier.Done;
begin
inherited Done;
end;
(****************************************************************************)
(*** *********************************************************)
(*** TMyApp *********************************************************)
(*** *********************************************************)
(****************************************************************************)
constructor TMyApp.Init;
var Bounds: TRect;
I: Integer;
begin
if not inherited Init then Fail;
SetScreenMode(smCO80 + smFont8x8);
Redraw;
Bounds.Assign(20, 4, 60, 44);
Damier := New(PDamier, Init(Bounds));
Desktop^.Insert(Damier);
end;
procedure TMyApp.InitMenuBar;
begin
MenuBar := Nil;
end;
procedure TMyApp.InitStatusLine;
var Bounds: TRect;
begin
Bounds.Assign(0, 49, 80 ,50);
StatusLine := New(PStatusLine, Init(Bounds, NewStatusDef(0, 0,
NewStatusKey('~Alt+X~ Exit', kbAltX, cmQuit, Nil), Nil)));
end;
procedure TMyApp.InitDesktop;
var Bounds: TRect;
begin
Bounds.Assign(0, 0, 80, 49);
Desktop := New(PDesktop, Init(Bounds));
end;
function TMyApp.GetPalette: PPalette;
const P: String[Length(CAppPalette)] = CAppPalette;
begin
GetPalette := @P;
end;
destructor TMyApp.Done;
begin
inherited Done;
end;
(****************************************************************************)
(*** *****************************************************************)
(*** Main *****************************************************************)
(*** *****************************************************************)
(****************************************************************************)
begin
MyApp.Init;
MyApp.Run;
MyApp.Done;
end. |
Partager