benjamind2011 wrote:1/ speed up the timer so that it redraws 100 times per second (currently it redraws 50 times per second). I'm not sure if this would make it smoother, but it might. I wanted to make some minor change to the scrolling code in SDash version to see if I could make it scroll smoother - even on my 100Hz CRT monitor it still doesn't scroll as smoothly as I'd like. Very minor problems, that doesn't affect the gameplay but would make it smoother on the eye.
In my boulder dash inspired game, The Probe, the redraw (frame-rate) is around 60FPS, and I have nice smooth scrolling...not sure if you need to up the redraw rate in GDASH...maybe the scrolling routine needs changing a bit? I don't know, I haven't tried it or looked at the code...
Here is some pseudo code for how The Probe is updated:
Code: Select all
const
cUpdateRate = 1/8; //8 FPS update rate for game, similar to boulder dash (~6 to 8 FPS)
type
TTheProbe = class
private
FUpdateTime: Single;
public
{...}
end;
procedure TTheProbe.UpdateFrame(aFrameTime: Single);
begin
FUpdateTime := FUpdateTime + aFrameTime;
if FUpdateTime >= cUpdateRate then
begin
FUpdateTime := FUpdateTime - cUpdateRate;
ScanLevel;
end;
RenderFrame;
end;
procedure TTheProbe.RenderFrame;
var
OfsX,OfsY: Single; // position offset of level object for soothscrolling (0,0) if not moving...
x,y,layer: Integer;
Obj : TEngineObject;
begin
{...}
for layer := cLowestLayer to cMaxLayer - 1 do
for y := 0 to FLevelHeight - 1
for x := 0 to FLevelWidth - 1 do
begin
Obj := GetObjectAt(layer,x,y);
OfsX := 0;
OfsY := 0;
// make object scroll offsets interpolate between old position (maximum offset)
// and current position (no offset) depending on the update time ratio
//
if Obj.MovingLeft then OfsX := +cTileWidth - cTileWidth * FUpdateTime / cUpdateRate
else if Obj.MovingRight then OfsX := -cTileWidth + cTileWidth * FUpdateTime / cUpdateRate
else if Obj.MovingUp then OfsY := +cTileHeight - cTileHeight * FUpdateTime / cUpdateRate
else if Obj.MovingDown then OfsY := -cTileHeight + cTileHeight * FUpdateTime / cUpdateRate;
// render object at tile position with any offsets due to scrolling
RenderObject(Obj,x,y,OfsX,OfsY);
end;
{...}
end;
The objects are scrolled (using offsets) depending on if they are moving + the update time's position
I don't know if this helps anyone?
cheers,
Paul