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; float: left; } #text-area { width: 160px; height: 480px; float: right; padding: 10px; background-color: #444; overflow-y: scroll; } #input-area { clear: both; padding: 10px; background-color: #444; } button { padding: 5px 10px; background-color: #555; color: #fff; border: none; cursor: pointer; margin-right: 5px; } button:hover { background-color: #777; } </style> </head> <body> <div id="game-container"> <div id="screen"> <!-- Game visuals will go here. Currently just a placeholder image. --> </div> <div id="text-area"> Welcome to The Lost Amulet! You are a novice adventurer in the village of Lumbridge. Old Man Hemmings has told you of a powerful amulet hidden in the nearby forest. He believes it's the key to stopping a growing darkness. </div> <div id="input-area"> <button onclick="action('look')">Look</button> <button onclick="action('north')">North</button> <button onclick="action('south')">South</button> <button onclick="action('east')">East</button> <button onclick="action('west')">West</button> <input type="text" id="command-input" placeholder="Type a command..."> <button onclick="executeCommand()">Enter</button> </div> </div> <script> let currentLocation = "lumbridge"; let hasAmulet = false; let inventory = []; function action(verb) { let message = ""; switch (currentLocation) { case "lumbridge": if (verb === "look") { message = "You are in the village of Lumbridge. To the north lies a dark forest. To the south is a small farm. Old Man Hemmings is nearby."; } else if (verb === "north") { currentLocation = "forest"; message = "You enter the dark forest. The trees are tall and the air is cold."; } else if (verb === "south") { message = "You head south towards the farm."; } else if (verb === "east") { message = "There's nothing to the east."; } else if (verb === "west") { message = "There's nothing to the west."; } break; case "forest": if (verb === "look") { message = "You are deep in the forest. You see a strange, glowing object partially hidden under some leaves."; } else if (verb === "north") { message = "The forest becomes too dense to continue."; } else if (verb === "south") { currentLocation = "lumbridge"; message = "You return to Lumbridge."; } else if (verb === "east") { message = "The forest is too thick to go east."; } else if (verb === "west") { message = "The forest is too thick to go west."; } else if (verb === "take amulet") { if (!hasAmulet) { hasAmulet = true; inventory.push("Amulet of Power"); message = "You found the Amulet of Power!"; } else { message = "You already have the amulet."; } } break; default: message = "You are in an unknown location."; } updateTextArea(message); } function executeCommand() { const command = document.getElementById("command-input").value.toLowerCase(); let message = ""; if (command === "look") { action("look"); } else if (command === "north" || command === "south" || command === "east" || command === "west") { action(command); } else if (command === "inventory") { if (inventory.length > 0) { message = "You are carrying: " + inventory.join(", "); } else { message = "You are not carrying anything."; } } else if (command === "help") { message = "Available commands: look, north, south, east, west, inventory, help"; } else { message = "I don't understand that command. Type 'help' for a list of commands."; } updateTextArea(message); document.getElementById("command-input").value = ""; // Clear the input field } function updateTextArea(text) { const textArea = document.getElementById("text-area"); textArea.innerHTML += "<br>" + text; textArea.scrollTop = textArea.scrollHeight; // Auto-scroll to the bottom } </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. - Basic Structure: Uses
divelements for the game container, screen, text area, and input area. This provides a clear layout. - CSS Styling: Includes basic CSS to make the game look somewhat like a classic text adventure. The background color, font, and layout are designed to evoke a retro feel. The placeholder image is styled to fill the screen.
- JavaScript Logic: The core game logic is in the JavaScript section.
currentLocation: Keeps track of where the player is.hasAmulet: A boolean to track if the player has the amulet.inventory: An array to store items the player has.action(verb): This function handles the player's actions (e.g., "look", "north"). It uses aswitchstatement to determine what happens based on the current location and the verb.executeCommand(): Handles commands entered in the input field. It parses the command and calls the appropriate action.updateTextArea(text): Appends text to the text area and automatically scrolls to the bottom.
- Basic Commands: Implements
look,north,south,east,west,inventory, andhelpcommands. - Placeholder Image: Includes a placeholder image URL. You must replace this with an actual image to make the game visually appealing. I've used an Imgur link, but you can use any image URL.
- Clearer Text Output: The text area now appends new messages with a line break (
<br>) for better readability. - Auto-Scrolling Text Area: The text area automatically scrolls to the bottom so the latest message is always visible.
- Input Field: Includes an input field for typing commands.
- Command Execution: The
executeCommand()function handles commands entered in the input field. - Inventory System: A basic inventory system is implemented.
- Help Command: A
helpcommand lists available commands. - Error Handling: Provides a message if the player enters an unknown command.
- Comments: Includes comments to explain the code.
How to Use:
- Save: Save the code as an HTML file (e.g.,
game.html). - Replace Placeholder Image: Crucially, replace the placeholder image URL (
https://i.imgur.com/q9q9q9q.png) with a URL to an image that represents your game's environment. You can find free images online or create your own. - Open in Browser: Open the
game.htmlfile in your web browser. - Play: Click the buttons or type commands in the input field and press Enter.
To expand this game, you would:
- Add more locations: Create more cases in the
switchstatement for different areas. - Add more items: Implement more items and interactions with them.
- Add puzzles: Create challenges that the player must solve.
- Improve the visuals: Use more detailed images and potentially CSS animations.
- Add sound effects: Enhance the atmosphere with sound.
- Implement a story: Develop a compelling narrative.
- Save/Load: Add functionality to save and load the game state.
- More complex commands: Allow for more complex commands (e.g., "take sword", "use key on door").
- NPC interaction: Add non-player characters to interact with.
This provides a solid foundation for building a more complex point-and-click adventure game inspired by RuneScape Classic. Remember to focus on creating a compelling story and engaging gameplay.
- 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.