feat: Implement pixel-art rendering with new level loading, tile maps, palettes, and pixel fonts, alongside a game over screen.
This commit is contained in:
parent
5b15e63ac3
commit
cf04677511
41 changed files with 793 additions and 331 deletions
|
|
@ -76,8 +76,12 @@ export class InputSystem extends System {
|
|||
if (this.engine && this.engine.canvas) {
|
||||
const canvas = this.engine.canvas;
|
||||
const rect = canvas.getBoundingClientRect();
|
||||
this.mouse.x = e.clientX - rect.left;
|
||||
this.mouse.y = e.clientY - rect.top;
|
||||
// Calculate scale factors between displayed size and internal resolution
|
||||
const scaleX = canvas.width / rect.width;
|
||||
const scaleY = canvas.height / rect.height;
|
||||
|
||||
this.mouse.x = (e.clientX - rect.left) * scaleX;
|
||||
this.mouse.y = (e.clientY - rect.top) * scaleY;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -96,8 +100,8 @@ export class InputSystem extends System {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update previous states - called at end of frame
|
||||
*/
|
||||
* Update previous states - called at end of frame
|
||||
*/
|
||||
updatePreviousStates() {
|
||||
// Deep copy current states to previous for next frame
|
||||
this.keysPrevious = {};
|
||||
|
|
@ -111,15 +115,15 @@ export class InputSystem extends System {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if a key is currently pressed
|
||||
*/
|
||||
* Check if a key is currently pressed
|
||||
*/
|
||||
isKeyPressed(key) {
|
||||
return this.keys[key.toLowerCase()] === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a key was just pressed (not held from previous frame)
|
||||
*/
|
||||
* Check if a key was just pressed (not held from previous frame)
|
||||
*/
|
||||
isKeyJustPressed(key) {
|
||||
const keyLower = key.toLowerCase();
|
||||
const isPressed = this.keys[keyLower] === true;
|
||||
|
|
@ -128,22 +132,22 @@ export class InputSystem extends System {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get mouse position
|
||||
*/
|
||||
* Get mouse position
|
||||
*/
|
||||
getMousePosition() {
|
||||
return { x: this.mouse.x, y: this.mouse.y };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mouse button is pressed
|
||||
*/
|
||||
* Check if mouse button is pressed
|
||||
*/
|
||||
isMouseButtonPressed(button = 0) {
|
||||
return this.mouse.buttons[button] === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mouse button was just pressed
|
||||
*/
|
||||
* Check if mouse button was just pressed
|
||||
*/
|
||||
isMouseButtonJustPressed(button = 0) {
|
||||
const isPressed = this.mouse.buttons[button] === true;
|
||||
const wasPressed = this.mouse.buttonsPrevious[button] === true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue