Skip to content

Commit 956328d

Browse files
committed
fix ratnap pos
1 parent 6e37a50 commit 956328d

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

client/src/playback/Actions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
184184
}
185185
},
186186
[schema.Action.RatNap]: class RatNapAction extends Action<schema.RatNap> {
187-
private static readonly OFFSET = { x: -0.35, y: 0 }
187+
// private static readonly OFFSET = { x: -0.35, y: 0 }
188188
apply(round: Round): void {
189189
// move the target onto the source adjust target's size using scale factor
190190
const src = round.bodies.getById(this.robotId)
@@ -205,7 +205,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
205205
target.beingCarried = true
206206

207207
target.lastPos = { ...target.pos }
208-
target.pos = { x: src.pos.x + RatNapAction.OFFSET.x, y: src.pos.y + RatNapAction.OFFSET.y }
208+
// target.pos = { x: src.pos.x + RatNapAction.OFFSET.x, y: src.pos.y + RatNapAction.OFFSET.y }
209209
target.size = 0.6
210210
}
211211
}
@@ -232,7 +232,6 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
232232
ctx.arcTo(srcCoords.x - half, srcCoords.y - half, srcCoords.x + half, srcCoords.y - half, radius)
233233
ctx.stroke()
234234
ctx.restore()
235-
ctx.restore()
236235
}
237236
},
238237
[schema.Action.RatCollision]: class RatCollisionAction extends Action<schema.RatCollision> {

client/src/playback/Bodies.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,13 @@ export class Body {
431431
}
432432

433433
public draw(match: Match, ctx: CanvasRenderingContext2D): void {
434+
const OFFSET = { x: .35, y: 0 } // to center the rat on the tile
435+
const ratnapped = this.robotType === schema.RobotType.RAT && this.beingCarried
436+
437+
if(ratnapped) this.pos.x += OFFSET.x
434438
const pos = this.getInterpolatedCoords(match)
439+
if(ratnapped) this.pos.x -= OFFSET.x
440+
435441
const renderCoords = renderUtils.getRenderCoords(pos.x, pos.y, match.currentRound.map.staticMap.dimension)
436442

437443
if (this.robotType == schema.RobotType.CAT) {

0 commit comments

Comments
 (0)