commit 736c552091e79eef78b13ea296f21415133ad4a2
Author: root <root@hub.scroll.pub> Date: 2024-12-27 17:38:26 +0000 Subject: Initial commit diff --git a/body.html b/body.html new file mode 100644 index 0000000..3ec6193 --- /dev/null +++ b/body.html @@ -0,0 +1,6 @@ +<div id="game-container"> + <div id="player" class="character"></div> + <div id="enemy" class="character"></div> + <div id="npc" class="character"></div> + <div id="message-box"></div> +</div> \ No newline at end of file diff --git a/index.scroll b/index.scroll new file mode 100644 index 0000000..80fbb8d --- /dev/null +++ b/index.scroll @@ -0,0 +1,8 @@ +buildHtml +baseUrl https://rpgquest.scroll.pub +metaTags +editButton /edit.html +title RPG Quest: A Browser-Based Adventure +style.css +body.html +script.js \ No newline at end of file diff --git a/prompt.json b/prompt.json new file mode 100644 index 0000000..633f9a7 --- /dev/null +++ b/prompt.json @@ -0,0 +1,25 @@ +{ + "id": "3381811e-a647-4310-a7ea-7217f04d6a0b", + "object": "chat.completion", + "created": 1735321091, + "model": "deepseek-chat", + "choices": [ + { + "index": 0, + "message": { + "role": "assistant", + "content": "---domain---\nrpgquest.scroll.pub\n---index.scroll---\nbuildHtml\nbaseUrl https://rpgquest.scroll.pub\nmetaTags\neditButton /edit.html\ntitle RPG Quest: A Browser-Based Adventure\nstyle.css\nbody.html\nscript.js\n---body.html---\n<div id=\"game-container\">\n <div id=\"player\" class=\"character\"></div>\n <div id=\"enemy\" class=\"character\"></div>\n <div id=\"npc\" class=\"character\"></div>\n <div id=\"message-box\"></div>\n</div>\n---style.css---\nbody {\n margin: 0;\n font-family: 'Arial', sans-serif;\n background-color: #1e1e1e;\n color: #fff;\n display: flex;\n justify-content: center;\n align-items: center;\n height: 100vh;\n overflow: hidden;\n}\n\n#game-container {\n position: relative;\n width: 800px;\n height: 600px;\n background-color: #333;\n border: 2px solid #555;\n overflow: hidden;\n}\n\n.character {\n position: absolute;\n width: 40px;\n height: 40px;\n background-color: #ff6347;\n border-radius: 50%;\n transition: all 0.2s ease;\n}\n\n#player {\n background-color: #00bfff;\n}\n\n#npc {\n background-color: #32cd32;\n}\n\n#message-box {\n position: absolute;\n bottom: 10px;\n left: 10px;\n width: 780px;\n padding: 10px;\n background-color: rgba(0, 0, 0, 0.8);\n border: 1px solid #555;\n color: #fff;\n text-align: center;\n display: none;\n}\n---script.js---\nconst player = document.getElementById('player');\nconst enemy = document.getElementById('enemy');\nconst npc = document.getElementById('npc');\nconst messageBox = document.getElementById('message-box');\n\nlet playerX = 400;\nlet playerY = 300;\nlet enemyX = 200;\nlet enemyY = 200;\nlet npcX = 600;\nlet npcY = 400;\n\nconst speed = 5;\nconst enemySpeed = 2;\nconst npcSpeed = 1;\nconst attackRange = 50;\nconst escapeThreshold = 20;\nlet enemyHealth = 100;\n\nfunction updatePositions() {\n player.style.left = `${playerX}px`;\n player.style.top = `${playerY}px`;\n enemy.style.left = `${enemyX}px`;\n enemy.style.top = `${enemyY}px`;\n npc.style.left = `${npcX}px`;\n npc.style.top = `${npcY}px`;\n}\n\nfunction movePlayer(direction) {\n switch (direction) {\n case 'ArrowUp': playerY -= speed; break;\n case 'ArrowDown': playerY += speed; break;\n case 'ArrowLeft': playerX -= speed; break;\n case 'ArrowRight': playerX += speed; break;\n }\n updatePositions();\n}\n\nfunction moveEnemy() {\n const dx = playerX - enemyX;\n const dy = playerY - enemyY;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n if (distance < attackRange) {\n enemyX += dx / distance * enemySpeed;\n enemyY += dy / distance * enemySpeed;\n if (distance < 10) {\n messageBox.textContent = 'Enemy attacks!';\n messageBox.style.display = 'block';\n setTimeout(() => messageBox.style.display = 'none', 1000);\n }\n } else if (enemyHealth < escapeThreshold) {\n enemyX -= dx / distance * enemySpeed;\n enemyY -= dy / distance * enemySpeed;\n } else {\n enemyX += Math.cos(Date.now() / 1000) * enemySpeed;\n enemyY += Math.sin(Date.now() / 1000) * enemySpeed;\n }\n updatePositions();\n}\n\nfunction moveNPC() {\n npcX += (Math.random() - 0.5) * npcSpeed;\n npcY += (Math.random() - 0.5) * npcSpeed;\n updatePositions();\n}\n\nnpc.addEventListener('click', () => {\n messageBox.textContent = 'NPC: Hello, adventurer!';\n messageBox.style.display = 'block';\n setTimeout(() => messageBox.style.display = 'none', 2000);\n});\n\ndocument.addEventListener('keydown', (e) => {\n if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {\n movePlayer(e.key);\n }\n});\n\nsetInterval(moveEnemy, 100);\nsetInterval(moveNPC, 100);\n---end---" + }, + "logprobs": null, + "finish_reason": "stop" + } + ], + "usage": { + "prompt_tokens": 467, + "completion_tokens": 1049, + "total_tokens": 1516, + "prompt_cache_hit_tokens": 0, + "prompt_cache_miss_tokens": 467 + }, + "system_fingerprint": "fp_f1afce2943" +} \ No newline at end of file diff --git a/readme.scroll b/readme.scroll new file mode 100644 index 0000000..8c112be --- /dev/null +++ b/readme.scroll @@ -0,0 +1,2 @@ +# rpgquest.scroll.pub +Website generated by DeepSeek from prompt: Create a browser based HTML RPG game: Generate in-line JavaScript code for a simple RPG game AI. The AI governs NPCs and enemies in a browser-based game. The AI should include: Features: Enemy AI Behavior: Basic Attack Logic: Enemies detect the player within a specific range and attack when in proximity. Patrol Mode: Enemies follow a predefined path when not engaged. Escape Mechanic: Enemies flee when their health drops below a threshold. NPC Behavior: Interaction Logic: NPCs respond to player actions, such as initiating dialogues when clicked. Movement Patterns: NPCs roam randomly within a defined area. Player Commands: Allow the player to control interactions (e.g., attack, talk) via simple button clicks or keypresses. HTML Integration: Render characters and environments using <div> elements styled with CSS. Update positions dynamically with JavaScript. Scalability: Code should be modular for adding more characters, behaviors, or levels. Output Example: Provide a minimal working example with: An enemy that patrols and attacks the player on proximity. An NPC that displays a message when clicked. Basic player movement with arrow keys. \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..f0af892 --- /dev/null +++ b/script.js @@ -0,0 +1,81 @@ +const player = document.getElementById('player'); +const enemy = document.getElementById('enemy'); +const npc = document.getElementById('npc'); +const messageBox = document.getElementById('message-box'); + +let playerX = 400; +let playerY = 300; +let enemyX = 200; +let enemyY = 200; +let npcX = 600; +let npcY = 400; + +const speed = 5; +const enemySpeed = 2; +const npcSpeed = 1; +const attackRange = 50; +const escapeThreshold = 20; +let enemyHealth = 100; + +function updatePositions() { + player.style.left = `${playerX}px`; + player.style.top = `${playerY}px`; + enemy.style.left = `${enemyX}px`; + enemy.style.top = `${enemyY}px`; + npc.style.left = `${npcX}px`; + npc.style.top = `${npcY}px`; +} + +function movePlayer(direction) { + switch (direction) { + case 'ArrowUp': playerY -= speed; break; + case 'ArrowDown': playerY += speed; break; + case 'ArrowLeft': playerX -= speed; break; + case 'ArrowRight': playerX += speed; break; + } + updatePositions(); +} + +function moveEnemy() { + const dx = playerX - enemyX; + const dy = playerY - enemyY; + const distance = Math.sqrt(dx * dx + dy * dy); + + if (distance < attackRange) { + enemyX += dx / distance * enemySpeed; + enemyY += dy / distance * enemySpeed; + if (distance < 10) { + messageBox.textContent = 'Enemy attacks!'; + messageBox.style.display = 'block'; + setTimeout(() => messageBox.style.display = 'none', 1000); + } + } else if (enemyHealth < escapeThreshold) { + enemyX -= dx / distance * enemySpeed; + enemyY -= dy / distance * enemySpeed; + } else { + enemyX += Math.cos(Date.now() / 1000) * enemySpeed; + enemyY += Math.sin(Date.now() / 1000) * enemySpeed; + } + updatePositions(); +} + +function moveNPC() { + npcX += (Math.random() - 0.5) * npcSpeed; + npcY += (Math.random() - 0.5) * npcSpeed; + updatePositions(); +} + +npc.addEventListener('click', () => { + messageBox.textContent = 'NPC: Hello, adventurer!'; + messageBox.style.display = 'block'; + setTimeout(() => messageBox.style.display = 'none', 2000); +}); + +document.addEventListener('keydown', (e) => { + if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) { + movePlayer(e.key); + } +}); + +setInterval(moveEnemy, 100); +setInterval(moveNPC, 100); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..ff61f07 --- /dev/null +++ b/style.css @@ -0,0 +1,50 @@ +body { + margin: 0; + font-family: 'Arial', sans-serif; + background-color: #1e1e1e; + color: #fff; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + overflow: hidden; +} + +#game-container { + position: relative; + width: 800px; + height: 600px; + background-color: #333; + border: 2px solid #555; + overflow: hidden; +} + +.character { + position: absolute; + width: 40px; + height: 40px; + background-color: #ff6347; + border-radius: 50%; + transition: all 0.2s ease; +} + +#player { + background-color: #00bfff; +} + +#npc { + background-color: #32cd32; +} + +#message-box { + position: absolute; + bottom: 10px; + left: 10px; + width: 780px; + padding: 10px; + background-color: rgba(0, 0, 0, 0.8); + border: 1px solid #555; + color: #fff; + text-align: center; + display: none; +} \ No newline at end of file