程序编译不成功,请大家帮看看是什么原因?(200分)

  • 主题发起人 主题发起人 rzman
  • 开始时间 开始时间
R

rzman

Unregistered / Unconfirmed
GUEST, unregistred user!
unit ugame;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXClass, StdCtrls, ExtCtrls, DXInput, DXDraws;

type
TMainForm = class(TDXForm)
DXDraw: TDXDraw;
TileMaps: TDXImageList;
DXTimer: TDXTimer;
DXInput: TDXInput;
Panel1: TPanel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure DXTimerActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure DrawTiles(StartX, StartY : Integer);
Type TTile = Record //DELPHI提示在这一行有错,我找不出原因来
TileImage : Integer;
end;
Type TTileMap = Record
Map:array[1..50,1..50] of TTile;
end;


public
{ Public declarations }
Map : TTileMap;
StartX, StartY : Integer;
end;




var
MainForm: TMainForm;

implementation

{$R *.dfm}

procedure TMainForm.DrawTiles(StartX, StartY : Integer);
var
PosX, PosY, LoopX, LoopY, XTile, YTile, NumOfTilesY, TileImage : Integer;
begin
PosY := 0;
PosX := 1;
NumOfTilesY := 1;
for LoopY := 1 to 50 do
begin
XTile := 1;
YTile := LoopY;
for LoopX := 1 to NumOfTilesY do
begin
TileImage := Map.Map[XTile, YTile].TileImage;
TileMaps.Items[TileImage].Draw(DXDraw. Surface,StartX + PosX + LoopX * 64, StartY + LoopY * 16, 0);
XTile := XTile + 1;
YTile := YTile - 1;
end;
NumOfTilesY := NumOfTilesY + 1;
PosX := PosX - 32;
PosY := PosY + 16;
end;

NumOfTilesY := NumOfTilesY - 2;
PosX := PosX + 64;
for LoopY := 1 to 49 do
begin
XTile := LoopY;
YTile := 3;
for LoopX := 1 to NumOfTilesY do
begin
TileImage := Map.Map[XTile, YTile].TileImage;
TileMaps.Items[TileImage].Draw(DXDraw. Surface, StartX + PosX + LoopX * 64, StartY + PosY + LoopY * 16, 0);
XTile := XTile + 1;
YTile := YTile - 1;
end;

NumOfTilesY := NumOfTilesY - 1;
PosX := PosX + 32;
end;

end;



procedure TMainForm.Button1Click(Sender: TObject);
begin
Close;
end;

procedure TMainForm.DXTimerActivate(Sender: TObject);
begin
if not DXDraw.CanDraw then Exit;
DXDraw.Surface.Fill(0);
Panel.Caption := 'FPS:' + InttoStr(DXTimer.FrameRate);
DrawTiles(StartX, StartY);
DXDraw.Flip;
DXInput.Update;
If isLeft in DXInput.States then StartX := StartX + 16;
If isRight in DXInput.States then StartX := StartX - 16;
If isUp in DXInput.States then StartY := StartY + 8;
If isDown in DXInput.States then StartY := StartY - 8;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
StartX := 1;
StartY := 1;
DXTimer.Enabled := True;
end;

end.


这是错误提示,请大家帮看一下
[Error] ugame.pas(22): 'END' expected but 'TYPE' found
[Error] ugame.pas(31): '=' expected but identifier 'Map' found
[Error] ugame.pas(31): '=' expected but ';' found
[Error] ugame.pas(32): '=' expected but ',' found
[Error] ugame.pas(32): '=' expected but ';' found
[Error] ugame.pas(35): 'IMPLEMENTATION' expected but ';' found
[Error] ugame.pas(40): '.' expected but 'IMPLEMENTATION' found
[Error] ugame.pas(17): Unsatisfied forward or external declaration: 'TMainForm.Button1Click'
[Error] ugame.pas(18): Unsatisfied forward or external declaration: 'TMainForm.DXTimerActivate'
[Error] ugame.pas(19): Unsatisfied forward or external declaration: 'TMainForm.FormCreate'
[Hint] ugame.pas(21): Private symbol 'DrawTiles' declared but never used
[Fatal Error] game.dpr(5): Could not compile used unit 'ugame.pas'

我是按照这里的例子来做的
http://airhand.blogdriver.com/airhand/190061.html
http://airhand.blogdriver.com/airhand/190068.html
 
哈,一堆的错误.有的忘了end,有的忘了;
 
Type TTile = Record
TileImage : Integer;
end;
Type TTileMap = Record
Map:array[1..50,1..50] of TTile;
end;

type
TMainForm = class(TDXForm)
DXDraw: TDXDraw;
TileMaps: TDXImageList;
DXTimer: TDXTimer;
DXInput: TDXInput;
Panel1: TPanel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure DXTimerActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure DrawTiles(StartX, StartY : Integer);
public
{ Public declarations }
Map : TTileMap;
StartX, StartY : Integer;
end;
 
procedure DrawTiles(StartX, StartY : Integer);
Type TTile = Record //DELPHI提示在这一行有错,我找不出原因来
TileImage : Integer;
end;
Type TTileMap = Record
Map:array[1..50,1..50] of TTile;
end;

无法在类的域里面定义什么类型的!
 

Type TTile = Record
TileImage : Integer;
end;
Type TTileMap = Record
Map:array[1..50,1..50] of TTile;
end;
放到uses语句与type语句之间的部分
 
谢谢flynow和royal1442,是的,我根据你们说的做了,现在没问题了,太谢谢了,看来我得去看看基础书才行了
如果可以,请留一下你们的联系方式给我可以吗?
我的QQ是 57458628

谢谢大家!
 
后退
顶部