Delphi 经典游戏程序设计40例 的学习 例21 立体迷宫【未完成】
unit R21; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TRei21 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Timer1: TTimer; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } procedure Make3D(Mx,My,Md:Byte;Bmap:TBitmap); end; const Yoko = 37; Tate = 27; LW = 12; Ymax = 14; Tmax = 14; var Rei21: TRei21; Lmap : array[0..Ymax,0..Tmax] of Byte = (); Dmap : array[0..4,0..4] of Byte; BackBmap : TBitmap; LX,LY,Dir :Byte; RectB,RectM : TRect; implementation {$R *.dfm} procedure TRei21.FormCreate(Sender: TObject); begin BackBmap := TBitmap.Create; BackBmap.Width := 30 * LW; BackBmap.Height := 30 * LW; LX := 1; LY := 1; Dir :=1; end; procedure TRei21.Make3D(Mx,My,Md:Byte;Bmap:TBitmap); var x,y : ShortInt; begin for x := 0 to 4 do for y := 0 to 4 do Dmap[x,y] := 1; case Md of // 方向 0: begin for x := 4 downto 0 do for y := -2 to 2 do if (Mx + x <= Ymax) and (My + y >= 0) and (My + y <= Tmax) then Dmap[y + 2,4 - x] := Lmap[Mx + x,My + y]; end; 1:begin for y := - 4 to 0 do for x := -2 to 2 do if (My + y >= 0) and (Mx + x >= 0) and (Mx + x <= Ymax) then Dmap[x + 2,y + 4] := Lmap[Mx + x,My + y]; end; 2:begin for x := -4 to 0 do for y := 2 downto -2 do if (Mx + x >= 0) and (My + y >= 0) and (My + y <= Tmax) then Dmap[2-y,4+x] := Lmap[Mx+x,My+y]; end; 3:begin for y:=4 downto 0 do for x:=2 downto -2 do if (My + y <= -Ymax) and (Mx + x >= 0) and (Mx + x <= Ymax) then Dmap[2 - x,4 - y] := Lmap[Mx + x,My + y]; end; end; Bmap.Canvas.Pen.Width := 2; Bmap.Canvas.Pen.Color := clWhite; Bmap.Canvas.Brush.Color := clBlack; Bmap.Canvas.Rectangle(0,0,Bmap.Width,Bmap.Height); for x := 0 to 4 do if (Dmap[x,0] and 1) = 1 then Bmap.Canvas.Rectangle(x * 6 * LW,12 * LW,(x * 6 + 6) * LW,18 * LW); if (Dmap[0,1] and 1) = 1 then Bmap.Canvas.Polygon(Point(0,10 * LW ), Point(0,20 * LW), Point(6 * LW ,18 * lw),Point(6 * LW ,12 * LW)); if (Dmap[1,1] and 1) = 1 then Bmap.Canvas.Polygon(Point(10 * LW,10 * LW),Pointer(10* lw,20 * lw), Point(12 * LW,18 * LW),Pointer(12 * lw,12 * lw)); end; end.
这个程序没有完成,看起来太魔性了,
纯粹用线条构成的立体图,
完全不能理解,里面画四边形用了一些数据,
应该是透视后规格,然后按照这个规格来画图

浙公网安备 33010602011771号