mirror of
https://github.com/MrEidam/bigredbutton.git
synced 2026-04-17 15:43:31 +00:00
122 lines
3.8 KiB
HTML
122 lines
3.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<!-- Google tag (gtag.js) -->
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-CTW2M8Q7SB"></script>
|
|
<script>
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
gtag('config', 'G-CTW2M8Q7SB');
|
|
</script>
|
|
<title>Document</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
form {
|
|
margin: 10px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<form id="keybindForm">
|
|
<label for="moveUp">Move Up:</label>
|
|
<input type="text" id="moveUp" name="moveUp" value="ArrowUp">
|
|
|
|
<label for="moveDown">Move Down:</label>
|
|
<input type="text" id="moveDown" name="moveDown" value="ArrowDown">
|
|
|
|
<label for="moveLeft">Move Left:</label>
|
|
<input type="text" id="moveLeft" name="moveLeft" value="ArrowLeft">
|
|
|
|
<label for="moveRight">Move Right:</label>
|
|
<input type="text" id="moveRight" name="moveRight" value="ArrowRight">
|
|
|
|
<label for="openShop">Open Shop:</label>
|
|
<input type="text" id="openShop" name="openShop" value="g">
|
|
|
|
<button type="button" onclick="updateKeybindings()">Update Keybindings</button>
|
|
</form>
|
|
|
|
<script>
|
|
// Your game logic goes here
|
|
|
|
// Default keybindings
|
|
let keybindings = {
|
|
moveUp: 'ArrowUp',
|
|
moveDown: 'ArrowDown',
|
|
moveLeft: 'ArrowLeft',
|
|
moveRight: 'ArrowRight',
|
|
openShop: 'g'
|
|
};
|
|
|
|
// Example variables
|
|
let playerX = 50;
|
|
let playerY = 50;
|
|
let playerSpeed = 5;
|
|
|
|
// Function to update game state
|
|
function update() {
|
|
// Update game logic here
|
|
}
|
|
|
|
// Function to render the game
|
|
function render() {
|
|
// Render game elements here
|
|
}
|
|
|
|
// Function to handle key presses
|
|
function handleKeyPress(event) {
|
|
// Use keybindings object to get the action associated with the pressed key
|
|
switch (event.key) {
|
|
case keybindings.moveUp:
|
|
playerY -= playerSpeed;
|
|
break;
|
|
case keybindings.moveDown:
|
|
playerY += playerSpeed;
|
|
break;
|
|
case keybindings.moveLeft:
|
|
playerX -= playerSpeed;
|
|
break;
|
|
case keybindings.moveRight:
|
|
playerX += playerSpeed;
|
|
break;
|
|
case keybindings.openShop:
|
|
// Call your shop function here
|
|
shop();
|
|
break;
|
|
}
|
|
|
|
// Update and render the game after key press
|
|
update();
|
|
render();
|
|
}
|
|
|
|
// Function to open the shop
|
|
function shop() {
|
|
// Your shop logic goes here
|
|
console.log('Opening the shop...' + ' with ' + keybindings.openShop);
|
|
}
|
|
|
|
// Attach the key press event listener to the document
|
|
document.addEventListener('keydown', handleKeyPress);
|
|
|
|
// Function to update keybindings based on user input
|
|
function updateKeybindings() {
|
|
keybindings.moveUp = document.getElementById('moveUp').value;
|
|
keybindings.moveDown = document.getElementById('moveDown').value;
|
|
keybindings.moveLeft = document.getElementById('moveLeft').value;
|
|
keybindings.moveRight = document.getElementById('moveRight').value;
|
|
keybindings.openShop = document.getElementById('openShop').value;
|
|
}
|
|
|
|
// Initial render
|
|
render();
|
|
</script>
|
|
</body>
|
|
</html> |