feat: Add block breaking, HUD, and inventory system for player
This commit is contained in:
12
js/input.js
12
js/input.js
@@ -18,14 +18,24 @@ window.addEventListener('keydown', (e) => {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Start breaking blocks with E key
|
||||
if (e.code === 'KeyE' && player) {
|
||||
player.startBreaking();
|
||||
}
|
||||
|
||||
// Prevent default behavior for game control keys
|
||||
if (['KeyW', 'KeyA', 'KeyS', 'KeyD', 'Space'].includes(e.code)) {
|
||||
if (['KeyW', 'KeyA', 'KeyS', 'KeyD', 'Space', 'KeyE'].includes(e.code)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('keyup', (e) => {
|
||||
keyState[e.code] = false;
|
||||
|
||||
// Stop breaking blocks when E key is released
|
||||
if (e.code === 'KeyE' && player) {
|
||||
player.stopBreaking();
|
||||
}
|
||||
});
|
||||
|
||||
function updatePlayerMovement() {
|
||||
|
||||
Reference in New Issue
Block a user