diff --git a/dist/img/modules/heavy_thruster_on.svg b/dist/img/modules/heavy_thruster_on.svg new file mode 100644 index 0000000..247f064 --- /dev/null +++ b/dist/img/modules/heavy_thruster_on.svg @@ -0,0 +1,121 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/dist/improcket.min.js b/dist/improcket.min.js index 1b06a04..e0460cd 100644 --- a/dist/improcket.min.js +++ b/dist/improcket.min.js @@ -89,7 +89,7 @@ const modules = { type: 'thruster', id: 'heavy', mass: 5, - value: 6, + value: 4, connectivity: [true, false, false, false], thrust: 40 }, @@ -99,7 +99,7 @@ const modules = { type: 'thruster', id: 'advanced', mass: 2, - value: 20, + value: 15, connectivity: [true, false, false, false], thrust: 30 } @@ -188,12 +188,12 @@ const images = { on: 'modules/light_thruster_on.svg' }, heavy: { - off: 'modules/light_thruster.svg', - on: 'modules/light_thruster_on.svg' + off: 'modules/heavy_thruster.svg', + on: 'modules/heavy_thruster_on.svg' }, advanced: { - off: 'modules/light_thruster.svg', - on: 'modules/light_thruster_on.svg' + off: 'modules/advanced_thruster.svg', + on: 'modules/advanced_thruster_on.svg' } }, connector: { @@ -608,6 +608,7 @@ let onupdate = () => {}; function init$1() { items.clear(); + update(); } function canToss() { @@ -1354,15 +1355,15 @@ function randomPlanet(x, y, { type: type }); - for (let i = 0.1; i < 4; i += 1) { - if (Math.random() > ENTITY_SPAWN_RATE) { + for (let i = 0.1; i < 10; i += 0.5) { + if (Math.random() > 0.95) { let e = randomEntity(); e.orbit(planet, i * radius, Math.random() * Math.PI * 2); } } - for (let i = 0; i < 5; i++) { - if (Math.random() > ENTITY_SPAWN_RATE || true) { + for (let i = 0; i < 10; i++) { + if (Math.random() > 0.7) { let e = randomEntity(); e.orbit(planet, 1.5, Math.random() * Math.PI * 2); e.gravity = false; @@ -1376,7 +1377,7 @@ function randomPlanet(x, y, { function randomEntity(x, y) { let entity; - if (Math.random() > 0.3) { + if (Math.random() > 0.5) { entity = new Entity(x, y, 'fuelcan'); } else { let type, id; @@ -1756,6 +1757,7 @@ function init$5() { window.addEventListener('wheel', event => { mouse.scroll = event.deltaY; + event.preventDefault(); }); window.addEventListener('contextmenu', event => { @@ -2702,8 +2704,8 @@ const TAU$1 = TAU; let canvas, context, tempCanvas, tempContext; let perspective; -let trace = false; -let markers = false; +let trace = true; +let markers = true; function init$8() { canvas = document.querySelector('#main'); @@ -2797,6 +2799,8 @@ class Perspective { this.targetZoom = DEFAULT_ZOOM; this.oldTarget = 0; this.oldShift = [0, 0]; + this.shiftX = 0; + this.shiftY = 0; this.oldZoom = 0; this.transition = 0; this.zoomTransition = 0; @@ -2939,7 +2943,9 @@ const mapping$1 = { toggleTrace: 'KeyT', toggleMarkers: 'KeyR', toggleMusic: 'KeyM', - togglePause: 'KeyP' + togglePause: 'KeyP', + zoomIn: 'KeyZ', + zoomOut: 'KeyX' }; let held, pressed; @@ -2956,7 +2962,17 @@ function tick$5() { if (!state.editing) { if (mouse.scroll !== 0) { - changeZoom(-mouse.scroll); + // Fix for Firefox. + let delta = mouse.scroll > 0 ? -50 : 50; + changeZoom(delta); + } + + if (held[mapping$1.zoomIn]) { + changeZoom(-10); + } + + if (held[mapping$1.zoomOut]) { + changeZoom(10); } if (pressed[mapping$1.togglePause] && !state.gameOver) { @@ -3055,6 +3071,8 @@ function changeView$1(view) { state.editing = false; state.paused = false; init$3(); + init$4(); + perspective.reset(); init$1(); } else if (view === 'instructions') { state.playing = false; diff --git a/js/assets.mjs b/js/assets.mjs index c343ee9..64c416f 100644 --- a/js/assets.mjs +++ b/js/assets.mjs @@ -25,12 +25,12 @@ export const images = { on: 'modules/light_thruster_on.svg' }, heavy: { - off: 'modules/light_thruster.svg', - on: 'modules/light_thruster_on.svg' + off: 'modules/heavy_thruster.svg', + on: 'modules/heavy_thruster_on.svg' }, advanced: { - off: 'modules/light_thruster.svg', - on: 'modules/light_thruster_on.svg' + off: 'modules/advanced_thruster.svg', + on: 'modules/advanced_thruster_on.svg' } }, connector: { diff --git a/js/data.mjs b/js/data.mjs index 82256ea..151e8cb 100644 --- a/js/data.mjs +++ b/js/data.mjs @@ -89,7 +89,7 @@ export const modules = { type: 'thruster', id: 'heavy', mass: 5, - value: 6, + value: 4, connectivity: [true, false, false, false], thrust: 40 }, @@ -99,7 +99,7 @@ export const modules = { type: 'thruster', id: 'advanced', mass: 2, - value: 20, + value: 15, connectivity: [true, false, false, false], thrust: 30 } diff --git a/js/game/control.mjs b/js/game/control.mjs index 846f387..950e2d8 100644 --- a/js/game/control.mjs +++ b/js/game/control.mjs @@ -17,7 +17,9 @@ export const mapping = { toggleTrace: 'KeyT', toggleMarkers: 'KeyR', toggleMusic: 'KeyM', - togglePause: 'KeyP' + togglePause: 'KeyP', + zoomIn: 'KeyZ', + zoomOut: 'KeyX' }; let held, pressed; @@ -34,7 +36,17 @@ export function tick() { if (!state.editing) { if (input.mouse.scroll !== 0) { - graphics.changeZoom(-input.mouse.scroll); + // Fix for Firefox. + let delta = input.mouse.scroll > 0 ? -50 : 50; + graphics.changeZoom(delta); + } + + if (held[mapping.zoomIn]) { + graphics.changeZoom(-10); + } + + if (held[mapping.zoomOut]) { + graphics.changeZoom(10); } if (pressed[mapping.togglePause] && !state.gameOver) { diff --git a/js/game/index.mjs b/js/game/index.mjs index ea27cff..65ff12e 100644 --- a/js/game/index.mjs +++ b/js/game/index.mjs @@ -40,6 +40,8 @@ export function changeView(view) { state.editing = false; state.paused = false; world.init(); + edit.init(); + graphics.perspective.reset(); inventory.init(); } else if (view === 'instructions') { state.playing = false; diff --git a/js/game/inventory.mjs b/js/game/inventory.mjs index b5972da..6d75bf6 100644 --- a/js/game/inventory.mjs +++ b/js/game/inventory.mjs @@ -14,6 +14,7 @@ let onupdate = () => {}; export function init() { items.clear(); + update(); } export function canToss() { diff --git a/js/graphics/index.mjs b/js/graphics/index.mjs index 762dadc..1cc6d5f 100644 --- a/js/graphics/index.mjs +++ b/js/graphics/index.mjs @@ -10,8 +10,8 @@ const TAU = consts.TAU; export let canvas, context, tempCanvas, tempContext; export let perspective; -export let trace = false; -export let markers = false; +export let trace = true; +export let markers = true; export function init() { canvas = document.querySelector('#main'); @@ -109,6 +109,8 @@ class Perspective { this.targetZoom = consts.DEFAULT_ZOOM; this.oldTarget = 0; this.oldShift = [0, 0]; + this.shiftX = 0; + this.shiftY = 0; this.oldZoom = 0; this.transition = 0; this.zoomTransition = 0; diff --git a/js/input.mjs b/js/input.mjs index 0a93bca..f72694e 100644 --- a/js/input.mjs +++ b/js/input.mjs @@ -45,6 +45,7 @@ export function init() { window.addEventListener('wheel', event => { mouse.scroll = event.deltaY; + event.preventDefault(); }); window.addEventListener('contextmenu', event => { diff --git a/js/world/spawn.mjs b/js/world/spawn.mjs index db2f1d2..872289e 100644 --- a/js/world/spawn.mjs +++ b/js/world/spawn.mjs @@ -80,15 +80,15 @@ function randomPlanet(x, y, { type: type }); - for (let i = 0.1; i < 4; i += 1) { - if (Math.random() > consts.ENTITY_SPAWN_RATE) { + for (let i = 0.1; i < 10; i += 0.5) { + if (Math.random() > 0.95) { let e = randomEntity(); e.orbit(planet, i * radius, Math.random() * Math.PI * 2); } } - for (let i = 0; i < 5; i++) { - if (Math.random() > consts.ENTITY_SPAWN_RATE || true) { + for (let i = 0; i < 10; i++) { + if (Math.random() > 0.7) { let e = randomEntity(); e.orbit(planet, 1.5, Math.random() * Math.PI * 2); e.gravity = false; @@ -102,7 +102,7 @@ function randomPlanet(x, y, { function randomEntity(x, y) { let entity, type, id; - if (Math.random() > 0.3) { + if (Math.random() > 0.5) { entity = new Entity(x, y, 'fuelcan'); } else { let type, id;