3D Doom-style Shooter
Prompt
Create a complete, simple 3D shooting game inspired by Doom using HTML, CSS, and JavaScript in a single HTML document. Requirements: 1. **3D Environment**: Build a basic navigable 3D world with obstacles and walls using WebGL or a similar 3D graphics library. The environment should allow the player to walk around freely. 2. **Player Movement**: Implement controls that allow the player to move forward, backward, strafe left and right (using keys like W, A, S, D), and look around in all directions using the mouse. 3. **Shooting Mechanism**: Allow the player to shoot projectiles. Implement simple collision detection to detect hits on enemies. 4. **Enemies**: Include at least one type of enemy that either moves toward the player or shoots back, making gameplay interactive. 5. **Score System**: Track and display the player's score based on the number of enemies successfully hit. 6. **Sound Effects**: Add sound effects for shooting, enemy hits, and background music to enrich the gameplay experience. Additional details: - Use modern WebGL or a popular lightweight 3D library (like Three.js) to manage 3D rendering and scene. - Optimize performance to ensure smooth gameplay in modern browsers. - Provide in-code comments to explain all key parts and logic for clarity. # Steps 1. Initialize the 3D scene, camera, and renderer. 2. Create basic geometry for environment walls and floor. 3. Set up player controls for movement and camera rotation. 4. Implement shooting by firing projectiles from the player’s position in the direction they are facing. 5. Create enemy objects, program simple AI to move towards or attack the player. 6. Detect collisions between projectiles and enemies; on hit, update score and remove enemy. 7. Add audio for shooting, enemy hits, and background music. 8. Display score on screen. # Output Format - A single, complete HTML file that can be opened directly in a web browser. - Embedded CSS for styling and JavaScript code (ES6 or later) for logic. - Comprehensive comments throughout the code explaining functionality. # Notes - Ensure compatibility with latest versions of major browsers (Chrome, Firefox, Edge). - Keep the code concise but modular for readability. - Use placeholder or public domain assets/sounds if needed. # Examples (Not needed here but code should be cleanly structured with comments explaining each major block, such as initializing scene, handling input, enemy AI, shooting logic, scoring, and sound.)
Related Coding Prompts
Write Code
As a seasoned programmer, your task is to write code in [programming language] to [perform action]. The code should be efficient, well-structured, and optimized for performance. Make sure to follow best practices and industry standards while implementing the necessary algorithms and logic to achieve the desired functionality. Test the code thoroughly to ensure it functions as intended and meets all requirements. Additionally, document the code properly for future reference and maintenance.
Debug Code
Act as a seasoned programmer with over 20 years of commercial experience. Analyze the provided [piece of code] that is causing a specific [error]. Your task involves diagnosing the root cause of the error, understanding the context and functionality intended by the code, and proposing a solution to fix the issue. Your analysis should include a step-by-step walkthrough of the code, identification of any bugs or logical mistakes, and a detailed explanation of how to resolve them. Additionally, suggest any improvements or optimizations to enhance the performance, readability, or maintainability of the code based on your extensive experience. Ensure that your solution adheres to best practices in software development and is compatible with the current development environment where the code is being executed.
Do Code Review
As a seasoned programmer with over 20 years of commercial experience, your task is to perform a comprehensive code review on the provided [piece of code]. Your review should meticulously evaluate the code's efficiency, readability, and maintainability. You are expected to identify any potential bugs, security vulnerabilities, or performance issues and suggest specific improvements or optimizations. Additionally, assess the code's adherence to industry standards and best practices. Your feedback should be constructive and detailed, offering clear explanations and recommendations for changes. Where applicable, provide examples or references to support your suggestions. Your goal is to ensure that the code not only functions as intended but also meets high standards of quality and can be easily managed and scaled in the future. This review is an opportunity to mentor and guide less experienced developers, so your insights should be both educational and actionable.