Hi,
I was playing a bit further with my program, and modified so I do the movement in the SpriteEngine.DoMove procedure , and it works fine regardles if velocity is 80, 95, or whatever... what I modified compared to my older source is :
TForm1.OnIDLE
Here is one obvious problem, which I did not even tried to solve... for now, somehow my Figure moves faster then the
screen is scroll. ( I was hoping the speed would be the same...but there is a slight difference... will play with it later... was not
the object here to solve that ... but rather to implement the movement more properly)
Code:
ActTime := ActTime + AdPerCounter.TimeGap;
if ActTime > 25 then
begin
Blurp.vx:=0;
Blurp.vy:=0;
if GetKeyState(VK_LEFT) < 0 then
begin
Blurp.vx:=-95;
AdSpriteEngine.X:=AdSpriteEngine.X-Blurp.vx*(AdPerCounter.TimeGap/1000);
end;
if GetKeyState(VK_RIGHT) < 0 then
begin
Blurp.vx:=95;
AdSpriteEngine.X:=AdSpriteEngine.X-Blurp.vx*(AdPerCounter.TimeGap/1000);
end;
if GetKeyState(VK_UP) < 0 then
begin
Blurp.vy:=-95;
AdSpriteEngine.Y:=AdSpriteEngine.Y-Blurp.vy*(AdPerCounter.TimeGap/1000);
end;
if GetKeyState(VK_DOWN) < 0 then
begin
Blurp.vy:=95;
AdSpriteEngine.Y:=AdSpriteEngine.Y-Blurp.vy*(AdPerCounter.TimeGap/1000);
end;
ActTime := 0;
end;
Here Is my modified DoMove , for now works great, been playing with it , using different velocity... always stops where it should yippeee
Code:
procedure TBlurp.DoMove(TimeGap: Double);
begin
inherited;
// left
if vx < 0 then
begin
if not testForWall(X+vx*TimeGap,Y,Image.Width,Image.Height-1,'left') then
begin
X:=X+round(vx*TimeGap) ;
end;
end;
// right
if vx > 0 then
begin
if not testForWall(X,Y,Image.Width,Image.Height-1,'right') then
begin
X:=X+round(vx*TimeGap);
end;
end;
// up
if vy < 0 then
begin
if not testForWall(X,Y+vy*TimeGap,Image.Width-1,Image.Height,'up') then
begin
Y:=Y+round(vy*TimeGap);
end;
end;
// down
if vy > 0 then
begin
if not testForWall(X,Y,Image.Width-1,Image.Height,'down') then
begin
Y:=Y+round(vy*TimeGap);
end;
end;
Collision;
end;
Also one unexpected sidefect is ... before it was important where my Start position for my character was... now it's not , X can be 128,139,131 ... it works the same.
Anyway I'll continue now with implementing gravity And checking the scrolling part.
Greetings
Rob
Bookmarks