Skip to content

Commit

Permalink
Seriously improved client smoothness at higher latency (the game is n…
Browse files Browse the repository at this point in the history
…ow still playable at 80ms ping!)
  • Loading branch information
Ohmnivore committed Jun 14, 2014
1 parent 1db5002 commit fe3bbcf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
Binary file modified Client/export/windows/cpp/bin/SkullRush.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Client/export/windows/cpp/bin/config.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.3.4
version=0.3.6
name=NOOB
team=1
ip=
Expand Down
2 changes: 1 addition & 1 deletion Client/source/SkullClient.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class SkullClient extends Client
Reg.state.playermap.set(Reg.state.player.ID, Reg.state.player);

FlxG.camera.follow(Reg.state.player);
FlxG.camera.followLerp = 15.0;
FlxG.camera.followLerp = 30.0;
}

if (MsgID == Msg.PlayerInfoAnnounce.ID)
Expand Down
22 changes: 16 additions & 6 deletions Shared/code/PlayerBase.hx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package ;
import enet.ENet;
import flash.utils.Timer;
import flixel.addons.effects.FlxTrail;
import flixel.addons.weapon.FlxBullet;
Expand Down Expand Up @@ -402,19 +403,28 @@ class PlayerBase extends FlxSprite
return Serializer.run(_arr);
}

public function lerp(v0:Float, v1:Float, t:Float):Float
{
return (1 - t) * v0 + t * v1;
}

public function c_unserialize(Arr:Array<Dynamic>):Void
{
_arr = Arr;

if (_arr.length == 14) //used to be 7
{
x = _arr[1];
y = _arr[2];
//velocity.x = ((_arr[1] - x) * 0.3 + _arr[7] * 0.5 + velocity.x * 0.2);
//velocity.y = ((_arr[2] - y) * 0.3 + _arr[8] * 0.4 + velocity.y * 0.3);

velocity.x = lerp(velocity.x, _arr[7], 0.4);
velocity.y = lerp(velocity.y, _arr[8], 0.4);

x = lerp(x, _arr[1], 0.8);
y = lerp(y, _arr[2], 0.8);

//velocity.x = (_arr[1] - x);
//velocity.y = (_arr[2] - y);
velocity.x = _arr[7];
velocity.y = _arr[8];
//x = _arr[1];
//y = _arr[2];

a = _arr[3];
isRight = _arr[4];
Expand Down

0 comments on commit fe3bbcf

Please sign in to comment.