uses Graph, Crt; const skUp = #72; skLeft =#75; skRight = #77; skDown = #80; kEsc = #27; var ErrCode: Integer; P1: pointer; S, x, y, sized, i, j: integer; Key, ScanKey: char; x1: integer; Sl: integer; CanExit: boolean; Time: longint absolute $0040: $006C; T: longint; BulletX, BulletY: integer; procedure GetKeys; begin Key := readkey; if Key = #0 then ScanKey := ReadKey else ScanKey := #0; end; procedure Wait; begin while T = Time do; T := Time; end; procedure ClearKeys; begin Key := #0; ScanKey := #0; end; procedure ClearKeyBoard; begin while KeyPressed do ReadKey; end; function Menu(Params: string): Integer; {not for DefaultFont!!!} var Count: integer; Strings: array [0 .. 15] of string [127]; i: integer; X, Y, H: integer; begin Count := 1; Strings[0] := ''; for i := 1 to Length(Params) do begin if Params[i] = #13 then begin Inc(Count); Strings[Count - 1] := ''; end else Strings[Count - 1] := Strings[Count - 1] + Params[i]; end; SetTextJustify(CenterText, CenterText); H := TextHeight('A') + 10; ClearDevice; SetColor(WHITE); for i := 0 to Count - 1 do OutTextXY(GetMaxX div 2, GetMaxY div 2 - (Count - 1) * H div 2 - H div 4 + i * H, Strings[i]); i := 0; repeat SetColor(GREEN); X := TextWidth(Strings[i]) + 10; Y := TextHeight(Strings[i]) + 10; Rectangle(GetMaxX div 2 - X div 2, GetMaxY div 2 - (Count - 1) * H div 2 + i * H - Y div 2, GetMaxX div 2 + X div 2, GetMaxY div 2 - (Count - 1) * H div 2 + i * H + Y div 2); GetKeys; SetColor(BLACK); Rectangle(GetMaxX div 2 - X div 2, GetMaxY div 2 - (Count - 1) * H div 2 + i * H - Y div 2, GetMaxX div 2 + X div 2, GetMaxY div 2 - (Count - 1) * H div 2 + i * H + Y div 2); if ScanKey = skUp then begin Dec(i); if i < 0 then i := Count - 1; end else if ScanKey = skDown then begin Inc(i); if i >= Count then i := 0; end; until Key = #13; Menu := i; end; procedure Init; var Gd, Gm: Integer; begin Gd := 9; Gm := 2; InitGraph(Gd, Gm, ''); if GraphResult <> grOK then Halt; CanExit := False; SetTextStyle(4, 0, 7); end; procedure Game; begin BulletX := 0; BulletY := -30; SetFillStyle(1, 4); SetColor(4); Line(110, 50, 110, 60); Line(110, 70, 110, 73); SetFillStyle(1, 1); SetColor(1); FillEllipse(110, 65, 20, 5); FloodFill(110, 65, 1); Line(130, 73, 90, 73); Sized := ImageSize(30, 50, 180, 50); GetMem(p1, Sized); GetImage(30, 56, 180, 90, p1^); ClearDevice; x := 225; y := 450; x1 := x; PutImage(x, y, p1^, XorPut); repeat SetColor(WHITE); Line(BulletX, BulletY, BulletX, BulletY + 10); Wait; if KeyPressed then GetKeys else ClearKeys; ClearKeyBoard; SetColor(BLACK); Line(BulletX, BulletY, BulletX, BulletY + 10); case ScanKey of skLeft : x1 := x - 10; skRight: x1 := x + 10; skUp: if BulletY <= -20 then begin BulletX := x + 80; BulletY := 450; end; end; if BulletY > -20 then BulletY := BulletY - 30; if (x1 < 0) or (x1 > GetMaxX - 150) then x1 := x; Putimage(x, y, p1^, XorPut); Putimage(x1, y, p1^, XorPut); x := x1; until Key=kEsc; FreeMem(p1, Sized); end; begin Init; repeat i := Menu('New'#13'About...'#13'Exit'); case i of 0: begin j := Menu('Easy'#13'Medium'#13'Hard'#13'Back'); case j of 0: Sl := 50; 1: Sl := 100; 2: Sl := 1; end; if j < 3 then Game; end; 1: begin ClearDevice; SetColor(LightBlue); OutTextXY(320,90,'Hello'); OutTextXY(320,190,'Press ENTER...'); repeat Key := ReadKey; if Key = #0 then ScanKey := ReadKey else ScanKey := #0; until Key = #13; end; 2: CanExit := True; end; until CanExit; CloseGraph; end.