@SilverWarrior ,
I did it, and to my dissapointment, it's worse then it was before on the other computer :
Code:procedure TMain.ATimer1Process(Sender: TObject); begin if StartDemo = true then ScrollMap; end;ATimer1.MaxFPS:=120;Code:procedure TMain.ATimer1Timer(Sender: TObject); begin // draw stuff , background is black ADevice1.Render(clBlack, True); // do stuff that require steady speed here ATimer1.Process; // flip backbuffers , make it visible ADevice1.Flip(); end;
ATimer1.Speed:=60;
Now even on my computer I get a hickup once... on the other computer constant hickups.
I've just tried to simply down my Scrollmap procedure to this :
My OnRender has only thisCode:procedure TMain.ScrollMap; var x,y,z : integer; i : integer; a,b,c : integer; begin if RanOnce = false then begin if MapOffset in [0..15] then begin MapOffset:=Map.MapLength-15; end; LineHeight:=0; GameDrawGrid; RanOnce:=true; end; if MapOffset > 0 then begin LineHeight:=LineHeight+ScrollSpeed; // Background : Layers [0..3], Tiles [0..19], Lines [0..15] of TBackGround; // Map.Record : Layers [0..3], Lines [0..Map.Length-1] , Tiles [0..19] // move available sprites down for y:=0 to 15 do for z:=0 to 3 do for x:=0 to 19 do begin if BackGround[z,x,y] <> nil then begin BackGround[z,x,y].Y:=BackGround[z,x,y].Y+ScrollSpeed; if BackGround[z,x,y].Y = 480 then begin BackGround[z,x,y].Y:=-32; end; end; end; // X loop end; // if Offset end;
ATimer1.MaxFPS:=1000;Code:procedure TMain.ADevice1Render(Sender: TObject); begin FPSEdit.Value:=ATimer1.FrameRate; SpriteEdit.Value:=SpriteEngine.Count; MemEdit.Text:=FormatFloat(',.# KB', CurrentMemoryUsage / 1024) ; if StartDemo = true then begin // ScrollMap; // AnimationPositionCalculator; end else begin if EditorAnimationCounter = 1000 then EditorAnimationCounter:=0; inc(EditorAnimationCounter,1); EditorXPos:=floor(myMouse.Position.X / (Panel1.Width / 20 )); EditorYPos:=floor(myMouse.Position.Y / (Panel1.Height / 15 )); with EditorCursor do begin X:=EditorXPos*32; Y:=EditorYPos*32; end; end; // SpriteEngine.Collision; SpriteEngine.Dead; SpriteEngine.Move(1); SpriteEngine.Draw; end;
ATimer1.Speed:=60;
And while the FPS is 1000 + on the other machine ( Windows 7 32bit, E3xxx, 3GB ram, 9800GTX+ ) , it does have hickups... and now I'm just scrolling existing sprites, I'm not updating, re-drawing, i'm just setting the position back to -32 . What am I possibly doing wrong here ? Is this not the way to go trough the sprites ? Is the Array causing the problem , the array I'm using to manipulate the sprites?
UPDATE : no-no-no-no
I've modified the code a bit further to see if the array can be the culprit :
This array is much larger then BackGround array. 18000 vs 960 things to check with IF . Guess the E7500 is fast enough not to make it noticable to go trough 960 ... but the E3xxx (Celeron....) is not.Code:for y:=0 to 15 do for z:=0 to 3 do for x:=0 to 19 do begin if Map.Layer[z].Lines[y+MapOffset-1,x].ImageIndex <> 0 then begin BackGround[z,x,y].Y:=BackGround[z,x,y].Y+ScrollSpeed; if BackGround[z,x,y].Y = 480 then begin BackGround[z,x,y].Y:=-32; end; end; end; // X loop
And now I have the same hickups on this faster computer, guess it takes to long to go trough the arra with if's like this, but how can I speed it up ? Can you give any tips ? ( and keeping it using array's , for now...)
UPDATE2:
I reran the code just to see it again, while I was googling for tips, changed nothing, and it runs smoothly on my machine again... with this
Code:for y:=0 to 15 do for z:=0 to 3 do for x:=0 to 19 do begin if Map.Layer[z].Lines[y+MapOffset-1,x].ImageIndex <> 0 then begin BackGround[z,x,y].Y:=BackGround[z,x,y].Y+ScrollSpeed; if BackGround[z,x,y].Y = 480 then begin BackGround[z,x,y].Y:=-32; end; end; end; // X loop
I'm getting pretty confused here, now it runs fine. Am I still doing something wrong here ? Or the Timer itself is playing with me...
UPDATE 3 :
re-wrote parts of the code to use Timer1.Process() . I've sepereated the Movement from the Line Creation . Sometimes it goes smooth on my computer, sometimes it's choppy on this one as well, as for the other "slower" machine it's choppy always even though I have 120FPS constantly...
I've attached the code, I think I'm having some serious problem understanding something here. Can you please take a quick look at the Timer.Process(), Device.Render() , DemoScrollMapLines(), DemoDrawMapLines() ?
Attached full source code, without exe.
I've looked again at the Diablo like example that comes with sprite engine, but there is nothin in Timer.Process() , guess because it's done using OnMove for all Objects, and OnMove is probably tied to Timer1.Speed ?
ps.: sorry a bit confused here, probably wrote to much
Greetings
Robert
Bookmarks