mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
fix controls
This commit is contained in:
parent
92c8877201
commit
f053915c65
|
@ -62,7 +62,7 @@
|
||||||
max-width: 60%;
|
max-width: 60%;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-block-end: 40px;
|
margin-block-end: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.red {
|
.red {
|
||||||
|
@ -110,8 +110,12 @@
|
||||||
.mobileControlsRow {
|
.mobileControlsRow {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobileControlsReset {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: 40px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 800px) {
|
@media (max-width: 800px) {
|
||||||
|
@ -169,7 +173,7 @@
|
||||||
<img id="mobileSelect" src="assets/SELECT.png" />
|
<img id="mobileSelect" src="assets/SELECT.png" />
|
||||||
<img id="mobileStart" src="assets/START.png" />
|
<img id="mobileStart" src="assets/START.png" />
|
||||||
</div>
|
</div>
|
||||||
<div class="mobileControlsRow">
|
<div class="mobileControlsRow mobileControlsReset">
|
||||||
<button id="mobileRestart">Restart</button>
|
<button id="mobileRestart">Restart</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -224,7 +228,7 @@
|
||||||
|
|
||||||
let previouslyPressedButtons = new Set();
|
let previouslyPressedButtons = new Set();
|
||||||
|
|
||||||
const dpadMovement = (touch) => {
|
const dpadMovement = (touches) => {
|
||||||
const currentlyPressed = new Set();
|
const currentlyPressed = new Set();
|
||||||
for (let touch of touches) {
|
for (let touch of touches) {
|
||||||
const target = touch.target.getBoundingClientRect();
|
const target = touch.target.getBoundingClientRect();
|
||||||
|
@ -262,18 +266,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let oldButton of previouslyPressedButtons) {
|
for (let oldButton of previouslyPressedButtons) {
|
||||||
if (!buttonsToPress.has(oldButton)) {
|
if (!currentlyPressed.has(oldButton)) {
|
||||||
releaseButton(oldButton);
|
releaseButton(oldButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let newButton of buttonsToPress) {
|
for (let newButton of currentlyPressed) {
|
||||||
if (!previouslyPressedButtons.has(newButton)) {
|
if (!previouslyPressedButtons.has(newButton)) {
|
||||||
pressButton(newButton);
|
pressButton(newButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
previouslyPressedButtons = buttonsToPress;
|
previouslyPressedButtons = currentlyPressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
mobileDpad.addEventListener("touchstart", (evt) =>
|
mobileDpad.addEventListener("touchstart", (evt) =>
|
||||||
|
@ -317,14 +321,12 @@
|
||||||
|
|
||||||
for (let oldTouch of mobileAbAPress) {
|
for (let oldTouch of mobileAbAPress) {
|
||||||
if (!currentTouches.has(oldTouch)) {
|
if (!currentTouches.has(oldTouch)) {
|
||||||
console.log("Release", oldTouch);
|
|
||||||
releaseButton(oldTouch);
|
releaseButton(oldTouch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let newTouch of currentTouches) {
|
for (let newTouch of currentTouches) {
|
||||||
if (!mobileAbAPress.has(newTouch)) {
|
if (!mobileAbAPress.has(newTouch)) {
|
||||||
console.log("Press", newTouch);
|
|
||||||
pressButton(newTouch);
|
pressButton(newTouch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue