Thank you,
I've changed onMove to
Code:
Left := Round(X);
Top := Round(Y);
Right := Round(X + Image.Width);
Bottom := Round(Y + Image.Height);
It still works,
but if I remove those +5,-8 it does not works for up,left,right
I forgot to mention my hero sprite is 30x60... does that mean.. I have do to it like
this ?
Code:
// up
if GetKeyState(VK_UP) < 0 then
begin
if (Self.Top+4 > TileBottom) and
(Self.Right-2 > TileLeft) and
(Self.Left+2 < TileRight) then
Y := TileBottom;
end;
// down
if GetKeyState(VK_DOWN) < 0 then
begin
if (Self.Bottom -4 < TileTop ) and
(Self.Right -2 > TileLeft) and
(Self.Left +2 < TileRight) then
Y := TileTop-60;
end;
// left
if GetKeyState(VK_LEFT) < 0 then
begin
if (Self.Left+2 > TileRight) and
(Self.Top+4< TileBottom) and
(Self.Bottom-4>TileTop) then
X := TileRight;
end;
// right
if GetKeyState(VK_RIGHT) < 0 then
begin
if (Self.Right-2 < TileLeft )and
(Self.Top+4< TileBottom) and
(Self.Bottom-4>TileTop) then
X := TileLeft -30;
end;
end;
It works, but honestly... it did not do any difference, my character can still enter a wall
from any direction if he is only like 1-2 pixel in the wall , I will try to draw this down maybe I'll understand it then why is it doing this... collision should stop it from getting in...or maybe I need to set the speed or something , I'll check vx, vy to 0 ...
Greetings
Robert
Bookmarks