ok well my code at the moment looks like this..
[pascal]var
Form4: TForm4;
arr: array[0..9, 0..9] of integer =
((1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
(2, 2, 1, 1, 1, 1, 1, 1, 2, 2),
(2, 1, 1, 2, 2, 2, 2, 1, 1, 2),
(2, 1, 2, 2, 2, 2, 2, 2, 1, 2),
(2, 1, 1, 1, 1, 1, 1, 1, 1, 2),
(2, 1, 1, 1, 1, 1, 1, 1, 1, 2),
(2, 1, 2, 2, 2, 2, 2, 2, 1, 2),
(2, 1, 0, 1, 2, 2, 1, 0, 1, 2),
(2, 2, 1, 2, 2, 2, 2, 1, 2, 2),
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2));
x: integer;
y: integer;
implementation
{$R *.dfm}
procedure TForm4.PaintBox1Paint(Sender: TObject);
begin
for x := 0 to 9 do begin
for y := 0 to 9 do begin
case arr[x, y] of
0: PaintBox1.Canvas.CopyRect(Rect(x*60, y*60, (x*60)+59,(y*60)+59),
BeerImg.Canvas,Rect(0,0,59,59));
1: PaintBox1.Canvas.CopyRect(Rect(x*60, y*60, (x*60)+59,(y*60)+59),
TileImg.Canvas,Rect(0,0,59,59));
2: PaintBox1.Canvas.CopyRect(Rect(x*60, y*60, (x*60)+59,(y*60)+59),
AsileImg.Canvas,Rect(0,0,59,59));
end;
end;
end;
end;
procedure TForm4.guy(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
mousex: integer;
mousey: integer;
blocked: boolean;
begin
mousex := X div 60;
mousey := Y div 60;
guyImg.Left := mousex * 60;
guyImg.Top := mousey * 60;
end;
procedure TForm4.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
blocked := guyImg.left-10;
if key = vk_up then guyImg.top:=guyImg.top-10;
if key = vk_right then guyImg.Left:=guyImg.Left+10;
if key = vk_down then guyImg.top:=guyImg.top+10;
if key = vk_left then guyImg.Left:=guyImg.Left-10;
end;
end.[/pascal]
basically i dont want the guy to go through the 2 tile. your code seems to something different to mine jsut by looking at it lol. so im confused. the first procedure in my code paints the map with a paint box. the second procedure is the movement via clicking which i dont really want to use so ignore that, and the third procedure is to just move the guy via the keys.
hopefully this will help you help me lol. thanks.
Bookmarks