diff options
author | elioat <elioat@tilde.institute> | 2024-12-27 08:15:13 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-27 08:15:13 -0500 |
commit | 3a4c1117bfc0b902fdec41467bc6528d2f7a6f6d (patch) | |
tree | 0fb77b1dcec44380f3949c505b1d5b5da3c9e196 /html/rogue | |
parent | a7fea5f379187ea7e7ff643215b801832459ed67 (diff) | |
download | tour-3a4c1117bfc0b902fdec41467bc6528d2f7a6f6d.tar.gz |
*
Diffstat (limited to 'html/rogue')
-rw-r--r-- | html/rogue/js/camera.js | 4 | ||||
-rw-r--r-- | html/rogue/js/config.js | 30 | ||||
-rw-r--r-- | html/rogue/js/game.js | 1 |
3 files changed, 17 insertions, 18 deletions
diff --git a/html/rogue/js/camera.js b/html/rogue/js/camera.js index c389b6e..aaeeea9 100644 --- a/html/rogue/js/camera.js +++ b/html/rogue/js/camera.js @@ -16,11 +16,11 @@ const Camera = { const centerX = state.canvas.width / 2; const centerY = state.canvas.height / 2; - // Calculate distance from center of screen + // Distance from center of the screen const deltaX = screenX - centerX; const deltaY = screenY - centerY; - // Only move camera if player is outside deadzone + // Only move the camera if the player is outside of the deadzone if (Math.abs(deltaX) > Config.camera.DEADZONE_X) { const adjustX = deltaX - (deltaX > 0 ? Config.camera.DEADZONE_X : -Config.camera.DEADZONE_X); this.x += adjustX * Config.camera.FOLLOW_SPEED; diff --git a/html/rogue/js/config.js b/html/rogue/js/config.js index 5a729e0..66c4916 100644 --- a/html/rogue/js/config.js +++ b/html/rogue/js/config.js @@ -1,37 +1,37 @@ const Config = { colors: { - BACKGROUND: 'rgba(135, 206, 235, 0.3)', // Pale blue - GRID: '#333333', // Off-black for grid lines - PLAYER: 'red', // Player color - HEX_FILL: '#ffffff' // White fill for passable hexes + BACKGROUND: 'rgba(135, 206, 235, 0.3)', + GRID: '#333333', + PLAYER: 'red', + HEX_FILL: '#ffffff' }, hex: { - SIZE: 40, // Base size of hexagons - GRID_SIZE: 10, // Number of hexes in grid (width/height) - get WIDTH() { // Computed hex width + SIZE: 40, // Size of a single hex + GRID_SIZE: 10, // Number of hexes in the grid (width/height) + get WIDTH() { // Computed hex width return this.SIZE * 2; }, - get HEIGHT() { // Computed hex height + get HEIGHT() { // Computed hex height return Math.sqrt(3) * this.SIZE; } }, game: { - FPS: 60, // Target frame rate - get FRAME_TIME() { // Computed frame duration + FPS: 60, + get FRAME_TIME() { return 1000 / this.FPS; } }, player: { - MOVE_SPEED: 0.1, // Player movement speed - SIZE_RATIO: 1/3 // Player size relative to hex size + MOVE_SPEED: 0.1, + SIZE_RATIO: 1/3 // The player's size relative to the hex size }, camera: { - FOLLOW_SPEED: 0.1, // Camera smoothing factor - DEADZONE_X: 200, // Horizontal deadzone in pixels - DEADZONE_Y: 150 // Vertical deadzone in pixels + FOLLOW_SPEED: 0.1, // Camera smoothing factor + DEADZONE_X: 200, // Horizontal deadzone in pixels + DEADZONE_Y: 150 // Vertical deadzone in pixels } }; \ No newline at end of file diff --git a/html/rogue/js/game.js b/html/rogue/js/game.js index e0010b7..d5891d7 100644 --- a/html/rogue/js/game.js +++ b/html/rogue/js/game.js @@ -26,7 +26,6 @@ function init() { requestAnimationFrame(gameLoop); } -// Draw a single hex function drawHex(ctx, x, y, hex) { const screenX = x - Camera.x; const screenY = y - Camera.y; |