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 {
|
class Player extends Entity {
|
||||||
constructor(x, y, options = {}) {
|
constructor(x, y, options = {}) {
|
||||||
super(ENTITY_TYPES.PLAYER, x, y, {
|
super(ENTITY_TYPES.PLAYER, x, y, {
|
||||||
width: 6, // Narrower collision box to match sprite
|
width: 3, // 50% smaller collision box width
|
||||||
height: 12, // Shorter collision box to match sprite
|
height: 6, // 50% smaller collision box height
|
||||||
...options
|
...options
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,9 +128,9 @@ class Player extends Entity {
|
|||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.translate(screenX, screenY);
|
ctx.translate(screenX, screenY);
|
||||||
|
|
||||||
// Use smaller dimensions for the sprite
|
// Use 50% smaller dimensions for the sprite
|
||||||
const spriteDisplayWidth = 24 * (PIXEL_SIZE / 2); // Smaller sprite (was 32)
|
const spriteDisplayWidth = 12 * (PIXEL_SIZE / 2); // 50% smaller sprite
|
||||||
const spriteDisplayHeight = 24 * (PIXEL_SIZE / 2); // Smaller sprite (was 32)
|
const spriteDisplayHeight = 12 * (PIXEL_SIZE / 2); // 50% smaller sprite
|
||||||
|
|
||||||
// Flip horizontally based on direction
|
// Flip horizontally based on direction
|
||||||
if (this.direction < 0) {
|
if (this.direction < 0) {
|
||||||
|
@ -103,7 +103,7 @@ function spawnPlayer() {
|
|||||||
|
|
||||||
// Create player at specified coordinates
|
// Create player at specified coordinates
|
||||||
// Position adjusted for proper sprite alignment with smaller sprite
|
// 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
|
// Focus camera on player
|
||||||
worldOffsetX = player.x - (canvas.width / PIXEL_SIZE / 2);
|
worldOffsetX = player.x - (canvas.width / PIXEL_SIZE / 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user