refactor: Reduce player size by 50% to improve pixel collision
This commit is contained in:
parent
d2ab5094ab
commit
bb1e25e753
@ -2,8 +2,8 @@
|
||||
class Player extends Entity {
|
||||
constructor(x, y, options = {}) {
|
||||
super(ENTITY_TYPES.PLAYER, x, y, {
|
||||
width: 6, // Narrower collision box to match sprite
|
||||
height: 12, // Shorter collision box to match sprite
|
||||
width: 3, // 50% smaller collision box width
|
||||
height: 6, // 50% smaller collision box height
|
||||
...options
|
||||
});
|
||||
|
||||
@ -128,9 +128,9 @@ class Player extends Entity {
|
||||
ctx.save();
|
||||
ctx.translate(screenX, screenY);
|
||||
|
||||
// Use smaller dimensions for the sprite
|
||||
const spriteDisplayWidth = 24 * (PIXEL_SIZE / 2); // Smaller sprite (was 32)
|
||||
const spriteDisplayHeight = 24 * (PIXEL_SIZE / 2); // Smaller sprite (was 32)
|
||||
// Use 50% smaller dimensions for the sprite
|
||||
const spriteDisplayWidth = 12 * (PIXEL_SIZE / 2); // 50% smaller sprite
|
||||
const spriteDisplayHeight = 12 * (PIXEL_SIZE / 2); // 50% smaller sprite
|
||||
|
||||
// Flip horizontally based on direction
|
||||
if (this.direction < 0) {
|
||||
|
@ -103,7 +103,7 @@ function spawnPlayer() {
|
||||
|
||||
// Create player at specified coordinates
|
||||
// Position adjusted for proper sprite alignment with smaller sprite
|
||||
player = createEntity(ENTITY_TYPES.PLAYER, 229, 45);
|
||||
player = createEntity(ENTITY_TYPES.PLAYER, 229, 40); // Adjusted Y position for smaller player
|
||||
|
||||
// Focus camera on player
|
||||
worldOffsetX = player.x - (canvas.width / PIXEL_SIZE / 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user