Skip to content

Commit

Permalink
fix more skipping bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
veu committed Sep 6, 2017
1 parent 2761b1a commit f8f93de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Draggable {
}
}

for (const event of ['onclick', 'onkeydown']) {
for (const event of ['onclick', 'onkeydown', 'onmouseup']) {
window[event] = e => {
if (!transitioning && !screens[currentScreen].s && screens[currentScreen][event]) {
screens[currentScreen][event](e);
Expand Down
57 changes: 33 additions & 24 deletions screens.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,14 @@ const screens = [
isHit: function (e) {
return hasHitCircle(e, this.x, this.y, 20);
},
move: async function (pos) {
move: function (pos) {
this.x = pos.x + 10;
clamp(this);
if (Math.abs(this.x) < 2) {
this.s = 1;
reset();
await wait(500);
transition();
} else {
reset();
this.x = 0;
}
reset();
},
render: function () {
ctx.strokeStyle = this.s ? '#fd9' : '#fff';
Expand All @@ -136,6 +133,12 @@ const screens = [
}
});
},
onmouseup: async function () {
if (this.line.s) {
await wait(500);
transition();
}
},
render: function () {
this.line.render();
drawLine(0, -20, [-12, -14, 12, 0, -12, 14]);
Expand Down Expand Up @@ -377,6 +380,12 @@ const screens = [
}
});
},
onmouseup: async function () {
if (this.t.s) {
await wait(500);
transition();
}
},
render: async function () {
this.t.render();
drawText('You are lost', 'center', 0, 40);
Expand All @@ -393,8 +402,6 @@ const screens = [

if (!this.d.length) {
this.t.s = 1;
await wait(500);
transition();
}
},
}),
Expand All @@ -404,19 +411,6 @@ const screens = [
}),
new Screen({
init: function () {
const startAnim = () => {
const i = setInterval(async () => {
this.o += 2;
this.e.y += 2;
reset();
if (this.o == 240) {
clearInterval(i);
await wait(500);
transition();
}
}, 33);
};

this.o = 0;
this.first = 1;
this.e = new Draggable(0, 34, {
Expand All @@ -437,13 +431,25 @@ const screens = [
if (Math.hypot(this.x - 147, this.y - 14) < 4) {
this.x = this.s = 147;
this.y = 14;
startAnim();
}

reset();
}
});
},
onmouseup: function () {
if (!this.e.s) return;
const i = setInterval(async () => {
this.o += 2;
this.e.y += 2;
reset();
if (this.o == 240) {
clearInterval(i);
await wait(500);
transition();
}
}, 33);
},
render: function () {
const left = -ctx.measureText('You are lost').width / 2;
if (this.first) {
Expand Down Expand Up @@ -545,6 +551,11 @@ const screens = [
}
}
},
onmouseup: async function () {
if (this.o.join('') != '123') return;
await wait(500);
transition();
},
render: async function () {
ctx.save();
ctx.lineWidth = 2;
Expand All @@ -561,8 +572,6 @@ const screens = [

if (this.o.length == 3) {
if (this.o.join('') == '123') {
await wait(500);
transition();
return;
}

Expand Down

0 comments on commit f8f93de

Please sign in to comment.