Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.01.26;
Скачать: CL | DM;

Вниз

Помогите заблудившемуся в дебрях Canvas a 8(   Найти похожие ветки 

 
Alexsey Orlov ©   (2003-07-09 21:08) [0]

Плиз выручите как сделать чтобы герой не врезался в стенку там както в массиве нао смастерить поиск следующего значения и исходя из етого смотреть стенка или нет только как ето сделать и как сделать на канвасе хотябы просенькую анимашку

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Buttons;

type
TForm1 = class(TForm)
SpeedButton2: TSpeedButton;
SpeedButton1: TSpeedButton;
procedure SpeedButton2Click(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
X,Y,xh,Number,ys,xs,yh:Integer;
i,j,temp:Integer;
DLivel:Byte;
Livel: array[0..10,0..10]of Byte =
((0,0,0,0,0,0,0,0,0,0,0),
(0,1,1,1,1,1,1,1,1,1,0),
(0,1,1,1,1,1,1,1,1,1,0),
(0,1,1,1,1,0,1,1,1,1,0),
(0,1,1,1,1,0,1,1,1,1,0),
(0,1,1,0,0,0,0,0,1,1,0),
(0,1,1,1,1,0,1,1,1,1,0),
(0,1,1,1,1,0,1,1,1,1,0),
(0,1,1,1,1,1,1,1,1,1,0),
(0,1,1,1,3,1,1,1,1,1,0),
(0,0,0,0,0,0,0,0,0,0,0));

implementation

{$R *.dfm}

procedure hero(x,y:Integer);
var
BitMap2: TBitMap;
begin
BitMap2 := TBitMap.Create;
try
xh:=x;
yh:=y;
xs:=i;
ys:=j;
BitMap2.LoadFromFile("hero.bmp");
Form1.Canvas.Draw(X,Y,BitMap2);
finally
BitMap2.Free;
end;
end;
procedure prov(fx,fy:integer);
begin
end;
procedure draw(x,y,Number:Integer);
var
BitMap1,BitMap2: TBitMap;
begin
BitMap1 := TBitMap.Create;
try
if Number=0 then
BitMap1.LoadFromFile("1.bmp");
if Number=1 then
BitMap1.LoadFromFile("2.bmp");
if Number=3 then begin
hero(x,y);
end;
Form1.Canvas.Draw(X,Y,BitMap1);
finally
BitMap1.Free;
end;
end;
procedure setlivel();
var
TextureHeight,TextureWidth:integer;
fgr:byte;
begin
For i := 0 to 10 do
For j := 0 to 10 do
Begin
Number := Livel[i,j];
X := J * 37;
Y := i * 34;
draw(X,Y,Number);
end;
end;

procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
setlivel();
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
xl,yl:integer;
BitMap1: TBitMap;
begin
if Key=VK_LEFT then begin
xl:=xs;
yl:=ys;
//Livel[xs,ys]:=0
Caption:=IntToStr(DLivel);
if (DLivel) -1<>0 then begin
xh:=xh-37;DLivel:=DLivel-1;
hero(xh,yh);
BitMap1 := TBitMap.Create;
try
BitMap1.LoadFromFile("2.bmp");
Form1.Canvas.Draw(Xh+37,Yh,BitMap1);
finally
BitMap1.Free;
end;
end;
end;
if Key=VK_RIGHT then begin
Caption:=IntToStr(DLivel);
if DLivel+1<>0 then begin
DLivel:=DLivel+1;
xh:=xh+37;
hero(xh,yh);
BitMap1 := TBitMap.Create;
try
BitMap1.LoadFromFile("2.bmp");
Form1.Canvas.Draw(Xh-37,Yh,BitMap1);
finally
BitMap1.Free;
end;
end;
end;
if Key=VK_UP then begin
yh:=yh-34;
hero(xh,yh);
BitMap1 := TBitMap.Create;
try
BitMap1.LoadFromFile("2.bmp");
Form1.Canvas.Draw(Xh,Yh+34,BitMap1);
finally
BitMap1.Free;
end;
end;
if Key=VK_DOWN then begin
yh:=yh+34;
hero(xh,yh);
BitMap1 := TBitMap.Create;
try
BitMap1.LoadFromFile("2.bmp");
Form1.Canvas.Draw(Xh,Yh-34,BitMap1);
finally
BitMap1.Free;
end;
end;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
temp:integer;
begin
temp:=Livel[j,i]+1;
Caption:=IntToStr(temp);
end;
end.
заранее спасибо
Alexsey Orlov


 
iXuSs   (2003-07-09 21:27) [1]

Грязный код, сложно с ходу разобраться. Выложи исходники куда-нибудь.



Страницы: 1 вся ветка

Текущий архив: 2004.01.26;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.019 c
14-83276
Думкин
2004-01-05 06:30
2004.01.26
С днем рождения! 5 января.


1-83195
xyz
2004-01-14 16:47
2004.01.26
Build with run time packages


1-83190
pvv
2004-01-13 16:39
2004.01.26
Как получить комментарий из ячейки Excel?


14-83250
Ермек
2004-01-06 02:32
2004.01.26
Помогите с FibPlus


6-83226
AndreySoft
2003-10-21 20:14
2004.01.26
Как программно установить IP-адрес