Siema!
Robię grę a'la GTA, i nie wiem co zrobiłem źle.
Oto kod na poruszanie się ludka, i wsiadanie/wysiadanie do/z samochodów:
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case key of
VK_Left: Guy.Left := Guy.Left -5;
VK_Right: Guy.Left := Guy.Left +5;
VK_Up: Guy.Top := Guy.Top -5;
VK_Down: Guy.Top := Guy.Top +5;
13:
if Guy.Visible = true then
begin
if Car1.Visible = false then
begin
Car1.Visible := true;
Guy.Picture := Guy_Texture.Picture;
Car1.Left := Guy.Left;
Car1.Top := Guy.Top;
end else
if Guy.Top < Car1.Top then
if Guy.Left < Car1.Left then
if Car1.Visible = true then
begin
Guy.Left := Car1.Left;
Guy.Top := Car1.Top;
Car1.Visible := false;
Guy.Picture := Car1_Texture.Picture;
end else
if Car2.Visible = false then
begin
Car2.Visible := true;
Guy.Picture := Guy_Texture.Picture;
Car2.Left := Guy.Left;
Car2.Top := Guy.Top;
end else
if Guy.Top < Car2.Top then
if Guy.Left < Car2.Left then
if Car2.Visible = true then
begin
Guy.Left := Car2.Left;
Guy.Top := Car2.Top;
Car2.Visible := false;
Guy.Picture := Car2_Texture.Picture;
end else
if Car3.Visible = false then
begin
Car3.Visible := true;
Guy.Picture := Guy_Texture.Picture;
Car3.Left := Guy.Left;
Car3.Top := Guy.Top;
end else
if Guy.Top < Car3.Top then
if Guy.Left < Car3.Left then
if Car3.Visible = true then
begin
Guy.Left := Car3.Left;
Guy.Top := Car3.Top;
Car3.Visible := false;
Guy.Picture := Car3_Texture.Picture;
end else
if Car.Visible = false then
begin
Car.Visible := true;
Guy.Picture := Guy_Texture.Picture;
Car.Left := Guy.Left;
Car.Top := Guy.Top;
end else
if Guy.Top < Car.Top then
if Guy.Left < Car.Left then
if Car.Visible = true then
begin
Guy.Left := Car.Left;
Guy.Top := Car.Top;
Car.Visible := false;
Guy.Picture := Car_Texture.Picture;
end;
end;
end;
end;
Kiedy włączam grę, wszystko jest ok, ludek chodzi, ale kiedy chcę wsiąść do jakiegoś samochodu, Od razu jest problem:
do 2 samochodów nie da się wsiąść, jeden jeśli jest wyżej od drugiego, to ludek zamiast wejść w niego, wchodzi w ten drugi itp.
Mam nadzieję, że ktoś rozszyfruje, o co tu chodzi, bo mam straszną ochotę na zagranie w już działającą wersję programu "Dandi GTA" (Oczywiście jest to nazwa wstępna) :P
Dzięks za wszystko, i mam nadzieję, że kogoś ten temat zainteresuje.
P.S. Nie mówcie mi nic o DelphiX, bo już mi to bokiem wychodzi :p