puck diameter
This commit is contained in:
parent
d17d5c594b
commit
92a7b44ca9
@ -38,6 +38,7 @@ export const GOAL_DECELERATION_RATE = 0.9; // Speed multiplier reduction after g
|
|||||||
export const MOVEMENT_STOP_THRESHOLD = 0.1; // meters - stop moving when this close to target
|
export const MOVEMENT_STOP_THRESHOLD = 0.1; // meters - stop moving when this close to target
|
||||||
|
|
||||||
// Puck constants
|
// Puck constants
|
||||||
|
export const PUCK_RADIUS = 0.2; // meters (regulation hockey puck is ~7.6cm diameter, make it larger to be visible)
|
||||||
export const PUCK_PICKUP_RADIUS = 1.5; // meters
|
export const PUCK_PICKUP_RADIUS = 1.5; // meters
|
||||||
export const PUCK_CARRY_DISTANCE = 1.0; // meters in front of player
|
export const PUCK_CARRY_DISTANCE = 1.0; // meters in front of player
|
||||||
export const MAX_PUCK_VELOCITY = 50; // m/s
|
export const MAX_PUCK_VELOCITY = 50; // m/s
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import Phaser from 'phaser';
|
import Phaser from 'phaser';
|
||||||
import { SCALE, MAX_PUCK_VELOCITY } from '../config/constants';
|
import { SCALE, MAX_PUCK_VELOCITY, PUCK_RADIUS } from '../config/constants';
|
||||||
import { CoordinateUtils } from '../utils/coordinates';
|
import { CoordinateUtils } from '../utils/coordinates';
|
||||||
import type { PuckState, TeamSide, Position } from '../types/game';
|
import type { PuckState, TeamSide, Position } from '../types/game';
|
||||||
|
|
||||||
@ -33,9 +33,10 @@ export class Puck extends Phaser.GameObjects.Container {
|
|||||||
|
|
||||||
this.body = this.body as Phaser.Physics.Arcade.Body;
|
this.body = this.body as Phaser.Physics.Arcade.Body;
|
||||||
|
|
||||||
// Set physics body size to match the puck visual (10px diameter)
|
// Set physics body size to match the puck visual (scaled from meters)
|
||||||
this.body.setSize(10, 10);
|
const puckDiameter = PUCK_RADIUS * 2 * SCALE;
|
||||||
this.body.setOffset(-5, -5); // Center the body on the container
|
this.body.setSize(puckDiameter, puckDiameter);
|
||||||
|
this.body.setOffset(-puckDiameter / 2, -puckDiameter / 2); // Center the body on the container
|
||||||
|
|
||||||
// Set max velocity (allow up to x m/s)
|
// Set max velocity (allow up to x m/s)
|
||||||
this.body.setMaxVelocity(MAX_PUCK_VELOCITY * SCALE, MAX_PUCK_VELOCITY * SCALE);
|
this.body.setMaxVelocity(MAX_PUCK_VELOCITY * SCALE, MAX_PUCK_VELOCITY * SCALE);
|
||||||
@ -48,21 +49,22 @@ export class Puck extends Phaser.GameObjects.Container {
|
|||||||
this.body.setCollideWorldBounds(true);
|
this.body.setCollideWorldBounds(true);
|
||||||
|
|
||||||
// Enable high-velocity collision detection
|
// Enable high-velocity collision detection
|
||||||
this.body.setCircle(5); // Use circular body instead of rectangle for better collision
|
this.body.setCircle(PUCK_RADIUS * SCALE); // Use circular body instead of rectangle for better collision
|
||||||
|
|
||||||
this.createSprite();
|
this.createSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
private createSprite() {
|
private createSprite() {
|
||||||
const graphics = this.scene.add.graphics();
|
const graphics = this.scene.add.graphics();
|
||||||
|
const puckRadius = PUCK_RADIUS * SCALE;
|
||||||
|
|
||||||
// Draw puck as black circle (5px radius)
|
// Draw puck as black circle
|
||||||
graphics.fillStyle(0x000000, 1);
|
graphics.fillStyle(0x000000, 1);
|
||||||
graphics.fillCircle(0, 0, 5);
|
graphics.fillCircle(0, 0, puckRadius);
|
||||||
|
|
||||||
// Add white highlight for visibility on ice
|
// Add white highlight for visibility on ice
|
||||||
graphics.fillStyle(0xffffff, 0.3);
|
graphics.fillStyle(0xffffff, 0.3);
|
||||||
graphics.fillCircle(-1, -1, 2);
|
graphics.fillCircle(-puckRadius / 2, -puckRadius / 2, puckRadius / 2);
|
||||||
|
|
||||||
this.add(graphics);
|
this.add(graphics);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user