more mobile stuff

This commit is contained in:
Corwin 2024-04-05 17:09:50 +01:00
parent e43d2d5a3e
commit 552f8f878d
No known key found for this signature in database
3 changed files with 125 additions and 115 deletions

View file

@ -6,7 +6,7 @@ import {
useState,
} from "react";
import mGBA from "./vendor/mgba";
import { KeyBindings } from "./bindings";
import { GbaKey, KeyBindings } from "./bindings";
import { styled } from "styled-components";
type Module = any;
@ -36,6 +36,8 @@ const MgbaCanvas = styled.canvas`
export interface MgbaHandle {
restart: () => void;
buttonPress: (key: GbaKey) => void;
buttonRelease: (key: GbaKey) => void;
}
export const Mgba = forwardRef<MgbaHandle, MgbaProps>(
@ -87,7 +89,7 @@ export const Mgba = forwardRef<MgbaHandle, MgbaProps>(
try {
mgbaModule.current.quitGame();
mgbaModule.current.quitMgba();
} catch {}
} catch { }
};
}, [state]);
@ -124,6 +126,8 @@ export const Mgba = forwardRef<MgbaHandle, MgbaProps>(
useImperativeHandle(ref, () => {
return {
restart: () => mgbaModule.current.quickReload(),
buttonPress: (key: GbaKey) => mgbaModule.current.buttonPress(key),
buttonRelease: (key: GbaKey) => mgbaModule.current.buttonRelease(key),
};
});

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>agbrs crash backtrace</title>
<style>
body {

View file

@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>agb - a rust framework for making Game Boy Advance games</title>
<style>
@ -20,12 +21,14 @@
flex-direction: column;
margin: 0;
}
h1,
h2,
h3 {
line-height: 1.2;
}
.gameDisplay > div {
.gameDisplay>div {
display: flex;
justify-content: center;
height: 100%;
@ -35,7 +38,7 @@
height: clamp(480px, 40vh, calc(100vw / 3));
max-width: 100vw;
margin-top: 20px;
overflow-x: hidden;
overflow: hidden;
}
.gameDisplay .imageWrapper {
@ -43,7 +46,7 @@
height: 100%;
}
.gameDisplay .imageWrapper > img {
.gameDisplay .imageWrapper>img {
height: 100%;
image-rendering: pixelated;
}
@ -56,7 +59,7 @@
}
header,
.help {
.desktopHelp {
max-width: 60%;
margin-left: auto;
margin-right: auto;
@ -78,7 +81,7 @@
max-width: 40rem;
}
.links > a {
.links>a {
text-decoration: none;
color: black;
background-color: #fad288;
@ -87,12 +90,13 @@
padding: 5px 10px;
}
.links > a:hover {
.links>a:hover {
border: solid black 2px;
}
</style>
</head>
<body>
</head>
<body>
<header>
<h1>agb - a rust framework for making Game Boy Advance games</h1>
</header>
@ -100,14 +104,14 @@
<div class="gameDisplay">
<div>
<div class="imageWrapper"><img src="assets/left.png" /></div>
<iframe
onload="this.contentWindow.focus()"
src="mgba/index.html#/assets/combo.gba"
></iframe>
<iframe id="gameFrame" onload="this.contentWindow.focus()" src="mgba/index.html#/assets/combo.gba"></iframe>
<div class="imageWrapper"><img src="assets/right.png" /></div>
</div>
</div>
<div class="help">
<div class="mobileControls">
</div>
<div class="desktopHelp">
<p>
Press escape to open the menu where you can view or change controls
and restart the game. The game provided is a combination of multiple
@ -123,5 +127,6 @@
<a href="book/">Book</a>
</div>
</section>
</body>
</body>
</html>