Added TurnAroundFramesToRecover.

This commit is contained in:
genxium 2023-01-19 09:20:52 +08:00
parent a82a238ce9
commit 9a8c32197e
10 changed files with 892 additions and 870 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,10 +9,10 @@
</data> </data>
</layer> </layer>
<objectgroup id="1" name="PlayerStartingPos"> <objectgroup id="1" name="PlayerStartingPos">
<object id="135" x="840" y="530"> <object id="135" x="1400" y="580">
<point/> <point/>
</object> </object>
<object id="137" x="959" y="532"> <object id="137" x="1500" y="580">
<point/> <point/>
</object> </object>
</objectgroup> </objectgroup>

File diff suppressed because it is too large Load Diff

View File

@ -362,7 +362,7 @@
"array": [ "array": [
0, 0,
0, 0,
209.57814771583418, 216.46608171234504,
0, 0,
0, 0,
0, 0,

View File

@ -537,7 +537,7 @@
"array": [ "array": [
0, 0,
0, 0,
209.57814771583418, 216.46608171234504,
0, 0,
0, 0,
0, 0,

View File

@ -96,7 +96,7 @@ cc.Class({
const p2Vpos = gopkgs.WorldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y); const p2Vpos = gopkgs.WorldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y);
const colliderRadiusV = gopkgs.WorldToVirtualGridPos(12.0, 0); const colliderRadiusV = gopkgs.WorldToVirtualGridPos(12.0, 0);
const speciesIdList = [4096, 1]; const speciesIdList = [1, 4096];
const chConfigsOrderedByJoinIndex = gopkgs.GetCharacterConfigsOrderedByJoinIndex(speciesIdList); const chConfigsOrderedByJoinIndex = gopkgs.GetCharacterConfigsOrderedByJoinIndex(speciesIdList);
const startRdf = window.pb.protos.RoomDownsyncFrame.create({ const startRdf = window.pb.protos.RoomDownsyncFrame.create({

View File

@ -169,30 +169,24 @@ cc.Class({
if (self.btnA) { if (self.btnA) {
self.btnA.on(cc.Node.EventType.TOUCH_START, function(evt) { self.btnA.on(cc.Node.EventType.TOUCH_START, function(evt) {
self._triggerEdgeBtnA(true); self._triggerEdgeBtnA(true);
evt.target.runAction(cc.scaleTo(0.1, 0.3));
}); });
self.btnA.on(cc.Node.EventType.TOUCH_END, function(evt) { self.btnA.on(cc.Node.EventType.TOUCH_END, function(evt) {
self._triggerEdgeBtnA(false); self._triggerEdgeBtnA(false);
evt.target.runAction(cc.scaleTo(0.1, 0.5));
}); });
self.btnA.on(cc.Node.EventType.TOUCH_CANCEL, function(evt) { self.btnA.on(cc.Node.EventType.TOUCH_CANCEL, function(evt) {
self._triggerEdgeBtnA(false); self._triggerEdgeBtnA(false);
evt.target.runAction(cc.scaleTo(0.1, 0.5));
}); });
} }
if (self.btnB) { if (self.btnB) {
self.btnB.on(cc.Node.EventType.TOUCH_START, function(evt) { self.btnB.on(cc.Node.EventType.TOUCH_START, function(evt) {
self._triggerEdgeBtnB(true); self._triggerEdgeBtnB(true);
evt.target.runAction(cc.scaleTo(0.1, 0.3));
}); });
self.btnB.on(cc.Node.EventType.TOUCH_END, function(evt) { self.btnB.on(cc.Node.EventType.TOUCH_END, function(evt) {
self._triggerEdgeBtnB(false); self._triggerEdgeBtnB(false);
evt.target.runAction(cc.scaleTo(0.1, 0.5));
}); });
self.btnB.on(cc.Node.EventType.TOUCH_CANCEL, function(evt) { self.btnB.on(cc.Node.EventType.TOUCH_CANCEL, function(evt) {
self._triggerEdgeBtnB(false); self._triggerEdgeBtnB(false);
evt.target.runAction(cc.scaleTo(0.1, 0.5));
}); });
} }
@ -500,13 +494,23 @@ cc.Class({
this.cachedBtnALevel = this.realtimeBtnALevel; this.cachedBtnALevel = this.realtimeBtnALevel;
this.btnAEdgeTriggerLock = true; this.btnAEdgeTriggerLock = true;
} }
if (rising) {
this.btnA.runAction(cc.scaleTo(0.1, 0.3));
} else {
this.btnA.runAction(cc.scaleTo(0.1, 0.5));
}
}, },
_triggerEdgeBtnB(rising) { _triggerEdgeBtnB(rising, evt) {
this.realtimeBtnBLevel = (rising ? 1 : 0); this.realtimeBtnBLevel = (rising ? 1 : 0);
if (!this.btnBEdgeTriggerLock && (1 - this.realtimeBtnBLevel) == this.cachedBtnBLevel) { if (!this.btnBEdgeTriggerLock && (1 - this.realtimeBtnBLevel) == this.cachedBtnBLevel) {
this.cachedBtnBLevel = this.realtimeBtnBLevel; this.cachedBtnBLevel = this.realtimeBtnBLevel;
this.btnBEdgeTriggerLock = true; this.btnBEdgeTriggerLock = true;
} }
if (rising) {
this.btnB.runAction(cc.scaleTo(0.1, 0.3));
} else {
this.btnB.runAction(cc.scaleTo(0.1, 0.5));
}
}, },
}); });

View File

@ -631,20 +631,34 @@ func ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(inputsBuffer *RingBuffer
} }
if 0 == currPlayerDownsync.FramesToRecover { if 0 == currPlayerDownsync.FramesToRecover {
isWallJumping := (currPlayerDownsync.Speed < intAbs(currPlayerDownsync.VelX))
/*
if isWallJumping {
fmt.Printf("joinIndex=%d is wall jumping\n{renderFrame.id: %d, currPlayerDownsync.Speed: %d, currPlayerDownsync.VelX: %d}\n", currPlayerDownsync.JoinIndex, currRenderFrame.Id, currPlayerDownsync.Speed, currPlayerDownsync.VelX)
}
*/
if 0 != effDx { if 0 != effDx {
xfac := int32(1) if !isWallJumping && 0 > effDx*thatPlayerInNextFrame.DirX {
if 0 > effDx { // [WARNING] A "turn-around", or in more generic direction schema a "change in direction" is a hurdle for our current "prediction+rollback" approach, yet applying a "FramesToRecover" for "turn-around" can alleviate the graphical inconsistence to a huge extent! For better operational experience, this is intentionally NOT APPLIED TO WALL JUMPING!
xfac = -xfac thatPlayerInNextFrame.DirX = effDx
} thatPlayerInNextFrame.VelX = 0
thatPlayerInNextFrame.DirX = effDx thatPlayerInNextFrame.FramesToRecover = chConfig.TurnAroundFramesToRecover
thatPlayerInNextFrame.DirY = effDy } else {
xfac := int32(1)
if 0 > effDx {
xfac = -xfac
}
thatPlayerInNextFrame.DirX = effDx
thatPlayerInNextFrame.DirY = effDy
thatPlayerInNextFrame.VelX = xfac * currPlayerDownsync.Speed if isWallJumping {
if intAbs(thatPlayerInNextFrame.VelX) < intAbs(currPlayerDownsync.VelX) { //fmt.Printf("joinIndex=%d is controlling while wall jumping\n{renderFrame.id: %d, currPlayerDownsync.Speed: %d, currPlayerDownsync.VelX: %d, effDx: %d}\n", currPlayerDownsync.JoinIndex, currRenderFrame.Id, currPlayerDownsync.Speed, currPlayerDownsync.VelX, effDx)
// Wall jumping thatPlayerInNextFrame.VelX = xfac * intAbs(currPlayerDownsync.VelX)
thatPlayerInNextFrame.VelX = xfac * intAbs(currPlayerDownsync.VelX) } else {
thatPlayerInNextFrame.VelX = xfac * currPlayerDownsync.Speed
}
thatPlayerInNextFrame.CharacterState = ATK_CHARACTER_STATE_WALKING
} }
thatPlayerInNextFrame.CharacterState = ATK_CHARACTER_STATE_WALKING
} else { } else {
thatPlayerInNextFrame.CharacterState = ATK_CHARACTER_STATE_IDLE1 thatPlayerInNextFrame.CharacterState = ATK_CHARACTER_STATE_IDLE1
thatPlayerInNextFrame.VelX = 0 thatPlayerInNextFrame.VelX = 0

View File

@ -15,8 +15,9 @@ type CharacterConfig struct {
GetUpInvinsibleFrames int32 GetUpInvinsibleFrames int32
GetUpFramesToRecover int32 GetUpFramesToRecover int32
Speed int32 Speed int32
JumpingInitVelY int32 JumpingInitVelY int32
JumpingFramesToRecover int32 // Not used yet
DashingEnabled bool DashingEnabled bool
OnWallEnabled bool OnWallEnabled bool
@ -25,6 +26,8 @@ type CharacterConfig struct {
WallJumpingInitVelY int32 WallJumpingInitVelY int32
WallSlidingVelY int32 WallSlidingVelY int32
TurnAroundFramesToRecover int32
SkillMapper SkillMapperType SkillMapper SkillMapperType
} }
@ -42,8 +45,11 @@ var Characters = map[int]*CharacterConfig{
GetUpInvinsibleFrames: int32(10), GetUpInvinsibleFrames: int32(10),
GetUpFramesToRecover: int32(27), GetUpFramesToRecover: int32(27),
Speed: int32(float64(2.0) * WORLD_TO_VIRTUAL_GRID_RATIO), Speed: int32(float64(2.5) * WORLD_TO_VIRTUAL_GRID_RATIO),
JumpingInitVelY: int32(float64(8) * WORLD_TO_VIRTUAL_GRID_RATIO), JumpingInitVelY: int32(float64(8) * WORLD_TO_VIRTUAL_GRID_RATIO),
JumpingFramesToRecover: int32(2),
TurnAroundFramesToRecover: int32(4),
DashingEnabled: false, DashingEnabled: false,
OnWallEnabled: false, OnWallEnabled: false,
@ -88,13 +94,16 @@ var Characters = map[int]*CharacterConfig{
GetUpInvinsibleFrames: int32(10), GetUpInvinsibleFrames: int32(10),
GetUpFramesToRecover: int32(27), GetUpFramesToRecover: int32(27),
Speed: int32(float64(2.0) * WORLD_TO_VIRTUAL_GRID_RATIO), Speed: int32(float64(2.6) * WORLD_TO_VIRTUAL_GRID_RATIO),
JumpingInitVelY: int32(float64(7.5) * WORLD_TO_VIRTUAL_GRID_RATIO), JumpingInitVelY: int32(float64(7.5) * WORLD_TO_VIRTUAL_GRID_RATIO),
JumpingFramesToRecover: int32(2),
TurnAroundFramesToRecover: int32(4),
DashingEnabled: true, DashingEnabled: true,
OnWallEnabled: true, OnWallEnabled: true,
WallJumpingFramesToRecover: int32(9), // 8 would be the minimum for an avg human WallJumpingFramesToRecover: int32(8), // 8 would be the minimum for an avg human
WallJumpingInitVelX: int32(float64(2.5) * WORLD_TO_VIRTUAL_GRID_RATIO), // Default is "appeared facing right", but actually holding ctrl against left WallJumpingInitVelX: int32(float64(2.8) * WORLD_TO_VIRTUAL_GRID_RATIO), // Default is "appeared facing right", but actually holding ctrl against left
WallJumpingInitVelY: int32(float64(7) * WORLD_TO_VIRTUAL_GRID_RATIO), WallJumpingInitVelY: int32(float64(7) * WORLD_TO_VIRTUAL_GRID_RATIO),
WallSlidingVelY: int32(float64(-1) * WORLD_TO_VIRTUAL_GRID_RATIO), WallSlidingVelY: int32(float64(-1) * WORLD_TO_VIRTUAL_GRID_RATIO),
@ -138,8 +147,11 @@ var Characters = map[int]*CharacterConfig{
GetUpInvinsibleFrames: int32(8), GetUpInvinsibleFrames: int32(8),
GetUpFramesToRecover: int32(30), GetUpFramesToRecover: int32(30),
Speed: int32(float64(1.9) * WORLD_TO_VIRTUAL_GRID_RATIO), Speed: int32(float64(2.0) * WORLD_TO_VIRTUAL_GRID_RATIO),
JumpingInitVelY: int32(float64(7.5) * WORLD_TO_VIRTUAL_GRID_RATIO), JumpingInitVelY: int32(float64(7.5) * WORLD_TO_VIRTUAL_GRID_RATIO),
JumpingFramesToRecover: int32(2),
TurnAroundFramesToRecover: int32(4),
DashingEnabled: false, DashingEnabled: false,
OnWallEnabled: false, OnWallEnabled: false,