Add music
This commit is contained in:
parent
194c0bf846
commit
bd97945e66
14 changed files with 82 additions and 20 deletions
|
@ -108,6 +108,7 @@ class Perspective {
|
|||
this.oldZoom = 0;
|
||||
this.transition = 0;
|
||||
this.zoomTransition = 0;
|
||||
this.zoomTransitionSpeed = 0.9;
|
||||
this.reset();
|
||||
}
|
||||
|
||||
|
@ -122,10 +123,11 @@ class Perspective {
|
|||
[this.shiftX, this.shiftY] = [x, y];
|
||||
}
|
||||
|
||||
changeZoom(zoom) {
|
||||
changeZoom(zoom, speed = 0.9) {
|
||||
this.oldZoom = this.currentZoom;
|
||||
this.targetZoom = zoom;
|
||||
this.zoomTransition = 1;
|
||||
this.zoomTransitionSpeed = speed;
|
||||
}
|
||||
|
||||
get currentShift() {
|
||||
|
@ -182,7 +184,7 @@ class Perspective {
|
|||
this.zoom = this.currentZoom;
|
||||
|
||||
this.transition *= 0.9;
|
||||
this.zoomTransition *= 0.9;
|
||||
this.zoomTransition *= this.zoomTransitionSpeed;
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
@ -201,7 +203,8 @@ class Perspective {
|
|||
|
||||
zoomDelta(delta) {
|
||||
let factor = 1 + (consts.ZOOM_SPEED * Math.abs(delta));
|
||||
this.targetZoom *= delta > 0 ? factor : 1 / factor;
|
||||
let target = this.targetZoom * (delta > 0 ? factor : 1 / factor);
|
||||
this.changeZoom(target, 0.7);
|
||||
this.normalize();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,9 @@ function renderParticle(particle) {
|
|||
function renderEntity(entity) {
|
||||
context.save();
|
||||
context.translate(...entity.com);
|
||||
if (graphics.perspective.zoom < 2 && graphics.markers) {
|
||||
context.globalAlpha = 0.7 / graphics.perspective.zoom;
|
||||
let alpha = Math.max(1 - ((graphics.perspective.zoom - 1) / 2), 0) ** 2;
|
||||
if (alpha > 0 && graphics.markers) {
|
||||
context.globalAlpha = alpha;
|
||||
context.beginPath();
|
||||
context.arc(0, 0, 4, 0, 2 * Math.PI);
|
||||
context.lineWidth = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue