@@ -98,6 +98,8 @@ class SlimeClient extends RealTimeClient {
9898export class SlimeGame extends RealTimeGame < SlimeClient > {
9999 mode : SlimeMode = $state ( defaultMode ( ) )
100100
101+ gameStart = Date . now ( )
102+ roundStart = 0
101103 status = GameStatus . IN_PLAY
102104 readonly p1 = new Player ( true )
103105 readonly p2 = new Player ( false )
@@ -177,7 +179,10 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
177179 }
178180
179181 protected override processRoundInfo ( m : ByteReader ) : void {
182+ this . gameStart = Date . now ( ) - Number ( m . getUint64 ( ) )
180183 if ( this . roundPlayers . length ) {
184+ this . roundStart = Date . now ( ) - Number ( m . getUint64 ( ) )
185+
181186 const flags = m . get ( )
182187 if ( this . roundPlayers . length > 1 && ( flags & 4 ) ) {
183188 [ this . roundPlayers [ 0 ] , this . roundPlayers [ 1 ] ] = [ this . roundPlayers [ 1 ] , this . roundPlayers [ 0 ] ]
@@ -251,6 +256,7 @@ export class SlimeGame extends RealTimeGame<SlimeClient> {
251256 this . p2 . respawn ( false )
252257 this . ball . respawn ( p0Serves )
253258 this . status = GameStatus . IN_PLAY
259+ this . roundStart = Date . now ( )
254260 }
255261
256262 protected override readonly playersSortProps = [
@@ -442,7 +448,8 @@ export class GameDrawer {
442448 } else if ( this . game . status === GameStatus . LOSS ) {
443449 status = 'You lost the round!'
444450 }
445- if ( status ) this . drawStatus ( ctx , W , H , status )
451+ const statusTime = `${ this . game . roundPlayers . length && ! this . game . status ? ( ( Date . now ( ) - this . game . roundStart ) / 1000 ) . toFixed ( 1 ) + '/' : '' } ${ ( ( Date . now ( ) - this . game . gameStart ) / 1000 ) . toFixed ( 1 ) } `
452+ this . drawStatus ( ctx , W , H , status ? `${ status } (${ statusTime } )` : statusTime )
446453 this . drawFPS ( ctx , W , H )
447454 }
448455
0 commit comments