Skip to content

Commit 4b33988

Browse files
committed
fix cat vision cone
1 parent 94c0770 commit 4b33988

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

client/src/playback/Bodies.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,18 +522,22 @@ export class Body {
522522
const maxX = Math.min(location.x + ceiledRadius, match.map.width - 1)
523523
const maxY = Math.min(location.y + ceiledRadius, match.map.height - 1)
524524

525-
const coords: Vector[] = [location]
525+
const coords: Vector[] = []
526+
526527
const halfFOV = fov / 2
527528
if (direction == 0) {
528529
return coords
529530
}
530531

532+
const OFFSET = this.robotType === schema.RobotType.CAT ? {x: 0.5, y: 0.5} : {x: 0, y: 0}
533+
const center = {x: location.x + OFFSET.x, y: location.y + OFFSET.y}
534+
531535
const directionRad = (directionAngles[direction] * Math.PI) / 180
532536

533537
for (let x = minX; x <= maxX; x++) {
534538
for (let y = minY; y <= maxY; y++) {
535-
const dx = x - location.x
536-
const dy = y - location.y
539+
const dx = x - center.x
540+
const dy = y - center.y
537541
if (dx * dx + dy * dy <= radius) {
538542
const angleToPoint = Math.atan2(dy, dx)
539543
let angleDiff = angleToPoint - directionRad

0 commit comments

Comments
 (0)