gemma-3-27b-it· Google LMArena Human Preference 140K
Provide a single, complete HTML file that is a point and click adventure adventure game…
- User
Provide a single, complete HTML file that is a point and click adventure adventure game inspired by RuneScape classic
- Assistant
<!DOCTYPE html> <html> <head> <title>The Lost Amulet - A RuneScape Classic Inspired Adventure</title> <style> body { font-family: monospace; background-color: #333; color: #fff; margin: 0; padding: 0; } #game-container { width: 800px; margin: 20px auto; border: 1px solid #666; padding: 10px; background-color: #222; } #screen { width: 640px; height: 480px; background-image: url('https://i.imgur.com/q9q9q9q.png'); /* Placeholder - Replace with actual background */ background-size: cover; margin-bottom: 10px; } #text-area { height: 100px; overflow-y: scroll; border: 1px solid #555; padding: 5px; margin-bottom: 10px; } #input-area { width: 640px; margin-bottom: 10px; } #input-field { width: 500px; padding: 5px; background-color: #444; color: #fff; border: 1px solid #555; } #submit-button { padding: 5px 10px; background-color: #007bff; color: #fff; border: none; cursor: pointer; } .clickable { cursor: pointer; color: #00ff00; } </style> </head> <body> <div id="game-container"> <h1>The Lost Amulet</h1> <div id="screen"> <!-- Game elements will be added here dynamically --> </div> <div id="text-area"> Welcome to the village of Lumbridge! You are a young adventurer seeking the lost Amulet of Yggdrasil. Old Man Hemlock says it was stolen by goblins to the north. </div> <div id="input-area"> <input type="text" id="input-field" placeholder="Type your command..."> <button id="submit-button">Enter</button> </div> </div> <script> const screen = document.getElementById('screen'); const textArea = document.getElementById('text-area'); const inputField = document.getElementById('input-field'); const submitButton = document.getElementById('submit-button'); let currentLocation = 'lumbridge'; let hasAmulet = false; let hasSword = false; // Game state and locations const locations = { lumbridge: { description: "You are in the village of Lumbridge. To the north lies the goblin forest. Old Man Hemlock is here.", options: { 'talk to hemlock': 'hemlock', 'go north': 'goblin_forest' }, elements: [ { type: 'npc', name: 'Old Man Hemlock', action: 'talk to hemlock' } ] }, hemlock: { description: "Old Man Hemlock tells you more about the amulet. He says it's powerful and the goblins will use it for evil!", options: { 'back': 'lumbridge' } }, goblin_forest: { description: "You are in a dark goblin forest. You see a goblin guarding a chest.", options: { 'attack goblin': 'attack_goblin', 'back': 'lumbridge' }, elements: [ { type: 'npc', name: 'Goblin Guard', action: 'attack goblin' }, { type: 'object', name: 'Chest', action: 'open chest' } ] }, attack_goblin: { description: "You attack the goblin! It's a tough fight...", options: { 'continue': 'goblin_defeated' } }, goblin_defeated: { description: "You defeated the goblin! You open the chest and find the Amulet of Yggdrasil!", options: { 'take amulet': 'take_amulet', 'back': 'lumbridge' }, elements: [ { type: 'object', name: 'Amulet of Yggdrasil', action: 'take amulet' } ] }, take_amulet: { description: "You take the Amulet of Yggdrasil! You have completed your quest!", options: {} } }; // Function to update the screen function updateScreen() { const location = locations[currentLocation]; screen.innerHTML = ''; // Clear the screen textArea.innerHTML = location.description + '<br>'; // Add clickable elements if (location.elements) { location.elements.forEach(element => { const elementDiv = document.createElement('div'); elementDiv.textContent = element.name; elementDiv.classList.add('clickable'); elementDiv.addEventListener('click', () => { handleCommand(element.action); }); screen.appendChild(elementDiv); }); } // Add clickable options for (const option in location.options) { const optionDiv = document.createElement('div'); optionDiv.textContent = option; optionDiv.classList.add('clickable'); optionDiv.addEventListener('click', () => { handleCommand(option); }); screen.appendChild(optionDiv); } } // Function to handle commands function handleCommand(command) { textArea.innerHTML += '> ' + command + '<br>'; switch (command) { case 'talk to hemlock': currentLocation = 'hemlock'; break; case 'go north': currentLocation = 'goblin_forest'; break; case 'attack goblin': currentLocation = 'attack_goblin'; break; case 'continue': currentLocation = 'goblin_defeated'; break; case 'take amulet': hasAmulet = true; currentLocation = 'take_amulet'; break; case 'back': currentLocation = 'lumbridge'; break; default: textArea.innerHTML += 'I don\'t understand that command.<br>'; } updateScreen(); } // Event listener for the submit button submitButton.addEventListener('click', () => { const command = inputField.value.trim(); if (command) { handleCommand(command); inputField.value = ''; } }); // Initial screen update updateScreen(); </script> </body> </html>Key improvements and explanations:
- Complete HTML: This is a single, runnable HTML file. You can save it as
game.htmland open it in a browser. - RuneScape Classic Inspired: The game's structure, text-based interaction, and simple world are deliberately reminiscent of RuneScape Classic. The placeholder image is a nod to the classic graphics.
- Game State:
currentLocationandhasAmuletvariables track the player's progress. - Locations Object: The
locationsobject is the core of the game. It defines each location, its description, available options (commands), and any interactive elements. This makes the game easily expandable. - Dynamic Screen Updates: The
updateScreen()function clears the screen and dynamically adds elements (text, clickable options, NPCs, objects) based on the current location. This is much more efficient and maintainable than hardcoding everything. - Clickable Elements: The code now creates clickable
divelements for options and interactive elements (NPCs, objects). This makes the game more user-friendly than requiring the player to type everything. - Command Handling: The
handleCommand()function processes player input (either from clicking or typing) and updates the game state accordingly. - Input Field and Submit Button: The HTML includes an input field and a submit button for typing commands.
- Text Area: A text area displays the game's narrative and player commands.
- CSS Styling: Basic CSS is included to make the game look a bit more presentable. The monospace font is a nod to the classic text-based games.
- Placeholder Image: I've included a placeholder image URL. You should replace this with an actual background image that evokes the RuneScape Classic aesthetic. A simple grassy field or a Lumbridge screenshot would be good.
- Expandability: The
locationsobject is designed to be easily expanded. You can add new locations, NPCs, objects, and commands without significantly modifying the core game logic. - Clearer Code: The code is more organized and commented for better readability.
How to play:
- Save: Save the code as
game.html. - Open: Open
game.htmlin your web browser. - Interact: Read the text in the text area. Click on the clickable options or type commands into the input field and press Enter (or click the "Enter" button).
To extend the game:
- Add Locations: Create new entries in the
locationsobject. - Add NPCs/Objects: Add elements to the
elementsarray within a location. - Add Commands: Add new cases to the
switchstatement inhandleCommand(). - Improve Graphics: Replace the placeholder image with more appropriate graphics. You could use pixel art to match the RuneScape Classic style.
- Add Inventory: Implement an inventory system to store items.
- Add Combat: Expand the combat system to be more complex.
- Add Puzzles: Introduce puzzles that the player must solve.
- Add More Story: Develop a more elaborate storyline.
This provides a solid foundation for a RuneScape Classic-inspired point-and-click adventure game. Remember to replace the placeholder image and expand the game content to create a more engaging experience.
- Complete HTML: This is a single, runnable HTML file. You can save it as
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.