Skip to content

Commit e9b14b9

Browse files
committed
updates and mobile controls
1 parent 2216927 commit e9b14b9

File tree

6 files changed

+104062
-98405
lines changed

6 files changed

+104062
-98405
lines changed

assets/style.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
--heightScreen: 583px;
44
--widthScreen: 800px;
55
--backgroundColor: white;
6-
--buttonSize: 50px;
6+
--buttonSize: 42px;
77
}
88

99
body {
@@ -30,7 +30,7 @@ canvas {
3030
margin-top: 50px;
3131
margin-bottom: 50px;
3232
height: var(--buttonSize);
33-
width: 100%;
33+
width: 85%;
3434
gap: 20px;
3535
display: flex;
3636
justify-content: center;
@@ -47,7 +47,7 @@ canvas {
4747

4848
.button {
4949
position: absolute;
50-
font-size: 35px;
50+
font-size: 30px;
5151
width: var(--buttonSize);
5252
height: var(--buttonSize);
5353
left: 50%;
@@ -68,6 +68,10 @@ canvas {
6868

6969
@media screen and (min-width: 768px) {
7070

71+
:root {
72+
--buttonSize: 50px;
73+
}
74+
7175
canvas {
7276
width: auto;
7377
height: auto;
@@ -78,6 +82,7 @@ canvas {
7882
}
7983

8084
.button {
85+
font-size: 35px;
8186
width: var(--buttonSize);
8287
height: var(--buttonSize);
8388
}

src/cassette.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ socket.on('turn', (data) => {
1414

1515
socket.on('button', (data) => {
1616
if (data.button == 'left') window.location.reload(false);
17-
if (data.button == 'right') pause();
17+
if (data.button == 'right') stop();
1818
});

src/controls.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@ function createUI() {
3131
controlsContainer = createDiv();
3232
controlsContainer.addClass("controlsContainer");
3333

34+
screenshotButtonContainer = createDiv();
35+
screenshotButtonContainer.addClass("buttonContainer");
36+
screenshotButtonContainer.parent(controlsContainer);
37+
38+
screenshotButton = createButton("⏺");
39+
screenshotButton.mousePressed(screenshotPage);
40+
screenshotButton.mouseReleased(releaseScreenshotButton);
41+
screenshotButton.touchStarted(screenshotPage);
42+
screenshotButton.touchEnded(releaseScreenshotButton);
43+
screenshotButton.addClass("button");
44+
screenshotButton.parent(screenshotButtonContainer);
45+
46+
restartButtonContainer = createDiv();
47+
restartButtonContainer.addClass("buttonContainer");
48+
restartButtonContainer.parent(controlsContainer);
49+
50+
restartButton = createButton("🔄");
51+
restartButton.mousePressed(restartPage);
52+
restartButton.mouseReleased(releaseRestartButton);
53+
restartButton.touchStarted(restartPage);
54+
restartButton.touchEnded(releaseRestartButton);
55+
restartButton.addClass("button");
56+
restartButton.parent(restartButtonContainer);
57+
58+
newWheelButtonContainer = createDiv();
59+
newWheelButtonContainer.addClass("buttonContainer");
60+
newWheelButtonContainer.parent(controlsContainer);
61+
62+
newWheelButton = createButton("⏏️");
63+
newWheelButton.mousePressed(ejectWheel);
64+
newWheelButton.mouseReleased(releaseEjectWheelButton);
65+
newWheelButton.touchStarted(ejectWheel);
66+
newWheelButton.touchEnded(releaseEjectWheelButton);
67+
newWheelButton.addClass("button");
68+
newWheelButton.parent(newWheelButtonContainer);
3469

3570
leftButtonContainer = createDiv();
3671
leftButtonContainer.addClass("buttonContainer");
@@ -49,8 +84,8 @@ function createUI() {
4984
pauseButtonContainer.parent(controlsContainer);
5085

5186
pauseButton = createButton("▶️");
52-
pauseButton.mousePressed(pause);
53-
// pauseButton.touchStarted(pause);
87+
pauseButton.mousePressed(stop);
88+
// pauseButton.touchStarted(stop);
5489
pauseButton.addClass("button");
5590
pauseButton.style("font-bold", "bolder");
5691
pauseButton.parent(pauseButtonContainer);
@@ -67,41 +102,6 @@ function createUI() {
67102
rightButton.addClass("button");
68103
rightButton.parent(rightButtonContainer);
69104

70-
newWheelButtonContainer = createDiv();
71-
newWheelButtonContainer.addClass("buttonContainer");
72-
newWheelButtonContainer.parent(controlsContainer);
73-
74-
newWheelButton = createButton("⏏️");
75-
newWheelButton.mousePressed(ejectWheel);
76-
newWheelButton.mouseReleased(releaseEjectWheelButton);
77-
newWheelButton.touchStarted(ejectWheel);
78-
newWheelButton.touchEnded(releaseEjectWheelButton);
79-
newWheelButton.addClass("button");
80-
newWheelButton.parent(newWheelButtonContainer);
81-
82-
restartButtonContainer = createDiv();
83-
restartButtonContainer.addClass("buttonContainer");
84-
restartButtonContainer.parent(controlsContainer);
85-
86-
restartButton = createButton("🔄");
87-
restartButton.mousePressed(restartPage);
88-
restartButton.mouseReleased(releaseRestartButton);
89-
restartButton.touchStarted(restartPage);
90-
restartButton.touchEnded(releaseRestartButton);
91-
restartButton.addClass("button");
92-
restartButton.parent(restartButtonContainer);
93-
94-
screenshotButtonContainer = createDiv();
95-
screenshotButtonContainer.addClass("buttonContainer");
96-
screenshotButtonContainer.parent(controlsContainer);
97-
98-
screenshotButton = createButton("⏺");
99-
screenshotButton.mousePressed(screenshotPage);
100-
screenshotButton.mouseReleased(releaseScreenshotButton);
101-
screenshotButton.touchStarted(screenshotPage);
102-
screenshotButton.touchEnded(releaseScreenshotButton);
103-
screenshotButton.addClass("button");
104-
screenshotButton.parent(screenshotButtonContainer);
105105
}
106106

107107
function updateUI() {
@@ -172,7 +172,7 @@ function keyReleased() {
172172
}
173173

174174
if (keyCode === 32) {
175-
pause();
175+
stop();
176176
}
177177

178178
if (keyCode === 38 || keyCode === 87) {
@@ -186,7 +186,7 @@ function keyReleased() {
186186
return false; // prevent any default behavior
187187
}
188188

189-
function pause() {
189+
function stop() {
190190
if (gamePaused) {
191191
unpauseGame();
192192
} else {

0 commit comments

Comments
 (0)