onlinecodesimulator/index.html

227 lines
5.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Learn CircuitPython</title>
<script src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.19.0/matter.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.39.0/min/vs/loader.js"></script>
<style>
/* Reset & base */
* {
box-sizing: border-box;
}
body,
html {
margin: 0;
padding: 0;
height: 100%;
font-family: Arial, sans-serif;
background-color: #fff;
display: grid;
grid-template-rows: auto 1fr auto;
grid-template-columns: 1fr;
min-height: 100vh;
}
/* ===== Header (top bar) ===== */
header {
background-color: #f3f4f6;
/* light gray */
padding: 16px 0;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.header-inner {
max-width: 960px;
margin: 0 auto;
padding: 0 16px;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 16px;
}
header h1 {
font-size: 1.5rem;
font-weight: bold;
margin: 0 0 4px 0;
color: #1f2937;
/* gray-800 */
}
header p {
margin: 0;
font-size: 0.875rem;
color: #4b5563;
/* gray-600 */
}
.button-group {
display: flex;
gap: 12px;
flex-wrap: wrap;
}
button {
cursor: pointer;
border: none;
border-radius: 6px;
padding: 8px 16px;
font-weight: 600;
color: white;
box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
transition: background-color 0.3s ease;
}
#compile-button {
background-color: #2563eb;
/* blue-600 */
}
#compile-button:hover {
background-color: #1d4ed8;
/* blue-700 */
}
#pause-button {
background-color: #eab308;
/* yellow-500 */
color: #000;
}
#pause-button:hover {
background-color: #ca8a04;
/* yellow-600 */
color: #000;
}
#reset-button {
background-color: #dc2626;
/* red-600 */
}
#reset-button:hover {
background-color: #b91c1c;
/* red-700 */
}
/* ===== Main Content ===== */
main {
display: flex;
justify-content: center;
padding: 16px;
background: #f9fafb;
}
.container {
width: 75vw;
/* about 12.5% margin on each side */
max-width: 1200px;
height: 800px;
display: flex;
gap: 20px;
background: white;
}
/* Monaco editor - left half */
#monaco-editor {
flex: 1;
border: 1px solid #d1d5db;
/* gray-300 */
height: 100%;
}
/* Right side: canvas + console */
.right-side {
flex: 1;
display: flex;
flex-direction: column;
gap: 12px;
height: 100%;
}
/* Canvas - top 2/3 */
#gameCanvas {
flex: 2;
border: 1px solid black;
width: 100%;
background: white;
}
#console {
flex: 1;
background: black;
color: white;
font-family: monospace, monospace;
padding: 8px;
overflow-y: auto;
border: 1px solid #d1d5db;
width: 100%;
}
/* alternate line colors */
#console > div:nth-child(odd) {
background-color: #222;
}
#console > div:nth-child(even) {
background-color: #111;
}
/* Responsive for smaller screens */
@media (max-width: 900px) {
.container {
flex-direction: column;
width: 95vw;
height: auto;
}
#monaco-editor,
.right-side {
height: 400px;
}
}
</style>
</head>
<body>
<!-- Top Bar with Heading and Buttons -->
<header>
<div class="header-inner">
<div>
<h1>Learn CircuitPython</h1>
<p>Write code, simulate physics, and see instant output</p>
</div>
<div class="button-group">
<button id="compile-button">Compile & Run</button>
<button id="pause-button">Pause</button>
<button id="reset-button">Reset</button>
</div>
</div>
</header>
<!-- Main Content -->
<main>
<div class="container">
<div id="monaco-editor"></div>
<div class="right-side">
<canvas id="gameCanvas"></canvas>
<div id="console"></div>
</div>
</div>
</main>
<script type="module">
import { initializeMonaco } from './game.js';
initializeMonaco();
</script>
</body>
</html>