Back to Learning

Coding

814 prompts available

2D Card Game Design

Create a unique web-based multiplayer game using HTML, CSS, and JavaScript, incorporating Firestore as the database. The game should be a turn-based 2D card selecting game featuring action cards: Shoot, Reload, and Shield. Implement the following game mechanics: - Players start with 100 HP. Each 'Shoot' card reduces the opponent's HP by 20. - The 'Reload' card allows a player to gain one additional 'Shoot' and can be used up to a total capacity of 5 shoots. - The 'Shield' card blocks one incoming 'Shoot'. Additional features to include: 1. **Play Again** option, only when both players agree. 2. **Leave** option to return to the main menu. 3. Functionality to **Create and Join Rooms** using Firestore, ensuring real-time updates for room management. # Steps 1. **Set Up the Environment**: - Initialize HTML, CSS, and JavaScript files. - Configure the Firestore database and establish a connection. 2. **Design the Game Interface**: - Use HTML and CSS to create a visually appealing layout. - Implement a user interface (UI) for card selection and display of scores. 3. **Game Mechanics**: - Implement turn-based logic using JavaScript. - Store and update player HP and card actions. - Enforce turn rules and implement card effects (Shoot, Reload, Shield). 4. **Database Integration**: - Use Firestore to manage room creation, player joining, and game state. - Ensure real-time synchronization for multiplayer interactions. 5. **Additional Features**: - Develop functionality for the Play Again feature based on both players' consent. - Enable the Leave option for returning to the main menu. # Output Format Provide the complete codeset including structured HTML, style-focused CSS, and functional JavaScript with Firestore integration. Ensure code comments for clarity and maintainability. # Examples - [Example of basic HTML for card layout] - [Example of JavaScript snippet for handling card actions] - [CSS snippet for styling the game interface] # Notes - Consider responsiveness for different screen sizes. - Ensure a smooth user experience with transitions and animations. - Make sure Firestore rules are configured for secure data transactions in the free tier.

2 MA Crossover EA MT5

Create an Expert Advisor (EA) for MetaTrader 5 (MT5) using MQL5 that implements a 2-MA crossover trading strategy. The EA should use the CTrade class for order management. Details: - Implement two moving averages (e.g., a fast MA and a slow MA). - Generate buy signals when the fast MA crosses above the slow MA. - Generate sell signals when the fast MA crosses below the slow MA. - Use the MQL5 CTrade class methods for opening and closing positions, managing orders safely. - Include parameters for the MA periods and type (e.g., EMA, SMA). - Manage trade position sizing and stop loss/take profit as needed. - Ensure the EA handles order states correctly (no duplicate orders). # Steps 1. Define input parameters for moving average periods, types, and trade parameters. 2. Calculate the current values of both MAs on each new tick. 3. Detect crossover events. 4. Use CTrade methods to open buy or sell trades upon crossovers. 5. Manage existing positions appropriately (e.g., close opposite positions). 6. Include error handling and logging. # Output Format Provide the full MQL5 source code (.mq5) for the Expert Advisor implementing the 2-MA crossover strategy using CTrade, fully commented and organized. # Notes - Make sure the EA can be easily adjusted with input parameters. - Follow MQL5 best practices for trading operations. - The output should be ready to compile and run in MT5 without further modification.

3D Blender Python Coding

As an expert 3D Blender designer, you will write Python scripts following specific instructions to create or modify 3D models in Blender. Use the Blender API efficiently and consider best practices to ensure the code is optimal and easy to understand. # Steps 1. Carefully interpret the instructions provided and identify the specific functionalities or modifications needed within Blender. 2. Utilize the Blender API to implement these functionalities. Ensure to properly access and manipulate Blender’s objects, materials, and scenes as required by the instructions. 3. Write clean, well-documented Python code, including comments to explain complex operations or Blender-specific API calls. 4. Test the Python script within Blender to verify that it performs the intended actions or modifications reliably. # Output Format Provide the Python script as text, formatted appropriately for readability. Each significant block of code should include comments explaining its purpose or function. # Examples ### Example 1 #### Task: Create a simple cube and apply a scale transformation ```python import bpy # Create a new cube bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0)) # Scale the cube cube = bpy.context.active_object cube.scale = (2, 2, 2) ``` ### Example 2 #### Task: Add a red material to the active object ```python import bpy # Get the active object obj = bpy.context.active_object # Create a new material mat = bpy.data.materials.new(name="RedMaterial") mat.diffuse_color = (1, 0, 0, 1) # RGBA for red # Assign the material to the object if len(obj.data.materials): obj.data.materials[0] = mat else: obj.data.materials.append(mat) ``` # Notes - Familiarity with Blender’s interface and manipulation of objects within a scene is essential. - The script should be compatible with the current Blender version, ensuring any deprecated features are avoided. - Consider edge cases such as applying transformations to an object that might not exist or handling materials if none are pre-assigned.

2D ECS Structure with SDL3

Create a 2D ECS (Entity Component System) structure using SDL3 that is optimized and fast for Windows. Ensure that the code is organized across multiple files instead of a single file, and provide all instructions and comments in English. ### Requirements: - Use SDL3 for graphics handling. - Implement an ECS architecture suitable for 2D games. - Optimize performance considerations in your design. - Split your code into multiple files: e.g., - `main.cpp` (Entry point) - `ecs.h` and `ecs.cpp` (ECS framework) - `component.h`, `component.cpp` (Components) - `system.h`, `system.cpp` (Systems) - `entity.h`, `entity.cpp` (Entities) - `game.h`, `game.cpp` (Game logic) - Ensure clarity and structure for maintainability. ### Steps: 1. **Set Up SDL3:** Initialize SDL3 and create a game window. 2. **ECS Structure:** Define the ECS structure: - Create structures for Entities, Components, and Systems. 3. **Entity Creation:** Implement functions to create and manage entities. 4. **Component Management:** Allow components to be attached to entities dynamically. 5. **System Processing:** Implement systems to update and render entities based on their components. 6. **Optimize:** Focus on optimizing both the code structure and the execution flow (e.g., minimize cache misses, reduce overhead). 7. **Testing:** Conduct tests to check performance and identify bottlenecks. ### Output Format - Provide complete code files as outputs that can be compiled and run in a Windows environment using a C++ compiler. - Include a README file documenting how to compile and run the application along with explanations of the code structure. ### Examples: - Example of an Entity definition: ```cpp struct Entity { int id; // Other relevant attributes }; ``` - Example of a component system: ```cpp class PositionComponent { float x, y; }; ``` ### Notes: - Focus on clarity and performance. - Comment your code thoroughly in English to describe functionality and design choices.

1-Minute Trading Script

You need to create a trading script that facilitates buying and selling decisions based on a 1-minute chart timeframe, by leveraging guidelines from a provided documentation link. --- # Steps 1. **Visit the Documentation**: Open the link provided and thoroughly read the relevant sections to comprehend the scripting framework. 2. **Identify Key Concepts**: Extract key information such as syntax, functions, or indicators necessary for a buy/sell script within this framework. 3. **Draft the Script**: - Configure the initial setup for a 1-minute chart environment. - Use basic market conditions or technical indicators, like moving averages or RSI, to establish buy and sell triggers. - Ensure that the script can efficiently process real-time market data. 4. **Refine and Optimize**: - Align the script with best practices mentioned in the documentation. - Implement tests and refine logic where necessary to improve accuracy and efficiency. # Output Format - Start with a brief comment section explaining the purpose of the script. - Develop the script using correct syntax as guided by the documentation. - Provide descriptive comments throughout the code to enhance readability. # Example ```javascript // Trading script for 1-minute buy/sell decisions // Implements a simple moving average crossover // Add indicators and commands as specified in the documentation ... ``` # Notes - Adapt specific indicators or conditions from the documentation when possible. - Ensure the script abides by any legal or exchange regulations as per the documentation. - Include exception handling and logging for robust functionality.

2EMA Strategy MT5 EA

Create an MT5 Expert Advisor (EA) trading bot using the MetaTrader 5 MQL5 language with the trade.mqh library that implements a 2 moving average trading strategy on the 5-minute timeframe using the 9 EMA and 36 EMA. Strategy details: 1. Indicators: - Calculate the 9-period Exponential Moving Average (EMA). - Calculate the 36-period Exponential Moving Average (EMA). 2. Entry Conditions: - Long Entry: - When the 9 EMA crosses above the 36 EMA (bullish crossover), wait for the price to retrace and touch the 9 EMA. - Enter a long trade at the close of the candle which touches the 9 EMA after the crossover. - Short Entry: - When the 9 EMA crosses below the 36 EMA (bearish crossover), wait for the price to retrace and touch the 9 EMA. - Enter a short trade at the close of the candle which touches the 9 EMA after the crossover. 3. Trade Management: - Initial Take Profit (TP): Set to 50 pips from the entry price. - Initial Stop Loss (SL): Set to 10 pips from the entry price. - After the trade moves favorably and reaches a profit of 25 pips: - Move the Stop Loss to the entry price (break-even) to secure the position. Implementation Requirements: - Use trade.mqh for trading operations. - The EA must run on the 5-minute timeframe. - Implement proper risk management respecting the TP and SL rules described. - Include necessary code comments explaining logic and calculations. # Output Format Provide the complete, well-structured MQL5 EA source code (.mq5) that fully implements the described strategy and can be compiled and run in MetaTrader 5. # Notes - Use appropriate functions to detect EMA crossover signals. - Ensure the EA waits correctly for the price to touch the 9 EMA after crossover before entering. - Make sure the SL is adjusted only after the trade reaches 25 pips profit. - Consider using appropriate pip-to-price conversions based on the instrument's point size and digits. - Include error checks for order placement and modifications. # Response Format Return the source code only with no additional explanation.

2 Player Side Scroller

Create a complete 2D side-scrolling platformer game in a single HTML file using HTML, CSS, and JavaScript. The game should support two players, each with independent controls for moving left, moving right, and jumping. Design fixed platforms (not randomly generated) arranged strategically across the level. Implement a flag that players must reach together to win the game. When both players reach the flag, display a win message indicating success. Key Requirements: - Single HTML file containing all code (HTML, CSS, JS). - Two players simultaneously playable with separate controls: - Player 1: [assign keys for left, right, and jump] - Player 2: [assign keys for left, right, and jump] - Side-scrolling mechanics with fixed platforms for players to jump on. - Collision detection for players and platforms. - A flag object positioned at the end of the level. - The game ends with a victory message only when both players reach the flag. - Clear and functional user input handling for both players. # Steps 1. Define the HTML structure including a canvas or game area. 2. Implement CSS styling to display the game area clearly. 3. Use JavaScript to: - Create player objects with positions, velocities, and controls. - Design fixed platforms at specific coordinates. - Handle user inputs for both players. - Implement physics for movement and jumping. - Perform collision detection with platforms. - Detect when each player reaches the flag. - Track if both players are at the flag and display a win message. # Output Format Provide a single, self-contained HTML file with embedded CSS and JavaScript that fully implements the described 2-player platformer game. The code should be well-organized, commented for readability, and ready to run by simply opening the HTML file in a web browser.

3D Bouncing Balls Cube

Create a complete three-dimensional simulation contained entirely within a single HTML file that features 50 realistic-looking balls bouncing inside a spinning cube. The 3D scene must include the following features: - The cube should slowly rotate around its center, providing a dynamic and continuously changing perspective. - Each of the 50 balls should be visually realistic and have proper shading or materials to differentiate them clearly from the cube and from each other. - The balls must move with realistic physics, including accurate velocity, acceleration, and collision detection. - The balls must bounce off the inner surfaces of the cube, reversing direction appropriately upon collision to simulate realistic bouncing behavior. Additional requirements: - Use only HTML and JavaScript (e.g., WebGL with Three.js or similar libraries embedded via CDN) within a single HTML file. - Ensure performance is smooth and the animation runs fluidly on modern browsers. - The camera perspective should allow a clear view of the bouncing balls inside the cube as it spins. - The solution should be self-contained, requiring no external assets beyond CDN links. # Steps 1. Set up a 3D scene with a cube mesh that can rotate slowly around its center. 2. Generate 50 spheres positioned initially inside the cube with random velocities. 3. Implement physics calculations to update the positions of balls each animation frame. 4. Detect collisions of balls against cube walls and update velocity vectors to simulate bouncing. 5. Render the updated scene at smooth frame rates. # Output Format Provide the complete HTML code as a single text block. This code should include all necessary HTML, CSS, and JavaScript so that saving it as an .html file and opening it in a modern web browser displays the described simulation immediately. # Notes - Focus on realistic motion and smooth rotation of the cube. - Optimize collision detection for 50 balls to maintain performance. - You can use publicly available JavaScript 3D libraries via CDN, but the entire solution must remain in one HTML file. # Response Formats ## prompt // Extracts the full prompt and metadata as valid JSON. {"prompt":"Create a complete three-dimensional simulation contained entirely within a single HTML file that features 50 realistic-looking balls bouncing inside a spinning cube.\n\nThe 3D scene must include the following features:\n\n- The cube should slowly rotate around its center, providing a dynamic and continuously changing perspective.\n- Each of the 50 balls should be visually realistic and have proper shading or materials to differentiate them clearly from the cube and from each other.\n- The balls must move with realistic physics, including accurate velocity, acceleration, and collision detection.\n- The balls must bounce off the inner surfaces of the cube, reversing direction appropriately upon collision to simulate realistic bouncing behavior.\n\nAdditional requirements:\n\n- Use only HTML and JavaScript (e.g., WebGL with Three.js or similar libraries embedded via CDN) within a single HTML file.\n- Ensure performance is smooth and the animation runs fluidly on modern browsers.\n- The camera perspective should allow a clear view of the bouncing balls inside the cube as it spins.\n- The solution should be self-contained, requiring no external assets beyond CDN links.\n\n# Steps\n\n1. Set up a 3D scene with a cube mesh that can rotate slowly around its center.\n2. Generate 50 spheres positioned initially inside the cube with random velocities.\n3. Implement physics calculations to update the positions of balls each animation frame.\n4. Detect collisions of balls against cube walls and update velocity vectors to simulate bouncing.\n5. Render the updated scene at smooth frame rates.\n\n# Output Format\n\nProvide the complete HTML code as a single text block. This code should include all necessary HTML, CSS, and JavaScript so that saving it as an .html file and opening it in a modern web browser displays the described simulation immediately.\n\n# Notes\n\n- Focus on realistic motion and smooth rotation of the cube.\n- Optimize collision detection for 50 balls to maintain performance.\n- You can use publicly available JavaScript 3D libraries via CDN, but the entire solution must remain in one HTML file.","name":"3D Bouncing Balls Cube","short_description":"Generates a 3D animation of 50 bouncing balls inside a rotating cube in a single HTML file.","icon":"CubeIcon","category":"programming","tags":["3D","Physics","Animation","HTML"],"should_index":true}

1-Minute Trading Script

Create a trading script for buying and selling on a 1-minute chart by following these guidelines: # Steps 1. **Visit the Documentation**: Access the provided link and thoroughly read the relevant sections to understand the scripting environment and any specific requirements. 2. **Identify Key Concepts**: Understand and note down specific syntax, functions, or indicators mentioned in the documentation that are suitable for creating a buy/sell trading script. 3. **Draft the Script**: - Configure the environment to operate on a 1-minute chart. - Implement basic buy and sell commands based on common indicators such as moving averages, RSI, or price crossovers that are appropriate for a 1-minute timeframe. - Ensure that the script is capable of processing real-time data efficiently. 4. **Refine and Optimize**: - Review the script to ensure it adheres to the best practices as described in the documentation. - Test the logic for accuracy and efficiency, refining as needed. # Output Format - Begin with a comment header that succinctly explains the functionality of the script. - Write the script code using the correct syntax identified in the documentation. - Thoroughly comment your code to enhance readability and aid understanding for others. # Example ```javascript // Trading script for 1-minute buy/sell decisions // Implements a simple moving average crossover ... ``` # Notes - Select and adapt specific indicators or market conditions from the provided documentation. - Ensure compliance with any legal or exchange-based regulations mentioned in the documentation. - Incorporate exception handling and logging to adhere to best practices.

2D Falling Stones Game Design

Create a comprehensive design and development prompt for a 2D HTML5 game scenario with the following detailed specifications: **Player Character:** - Positioned at the bottom side of the screen. - Continuously fires projectiles upward without player input to fire. - Moves horizontally forward and backward in response to controller inputs (e.g., arrow keys or gamepad sticks). - Movement should be smooth and responsive with no lag. **Enemy Behavior (Falling Stones):** - Large stones fall from the top of the screen toward the bottom. - Each stone is initially part of a group of 2 stones. - When a stone is hit by the player’s projectile, it splits into two smaller stones, doubling the group count from 2 to 4. - This splitting process continues progressively, with each split halving the size of stones. - Stones continue falling downward with smooth, natural animation. **Splitting Mechanics:** - Upon projectile impact, each stone splits immediately into two smaller stones. - The new stones should separate visually and move in slightly diverging directions as they fall. - There should be a limit or minimum stone size after which stones no longer split. **Animation Requirements:** - The entire scene must be fully animated with smooth, fluid movements: - Player movement left and right. - Continuous firing animations. - Falling stones. - Stone splitting and size reduction. - Visual feedback when a stone is hit (e.g., flash, sound, small explosion animation). **Player Controls Specification:** - Use keyboard arrow keys or a standard controller/gamepad for horizontal movement. - No button required to fire; firing happens automatically at preset intervals. - Ensure controls are responsive and support continuous left/right movement without lag. **Additional Requirements:** - Use HTML5 canvas or equivalent for rendering. - Optimize for smooth 60 FPS animation. - Clearly specify all relevant variables and parameters (player speed, firing rate, stone speed, stone sizes, split mechanics). -- This prompt should guide the development or design team to implement a polished, interactive 2D game feature aligning with the described gameplay mechanics and animation standards.

2D Fighting Game in Colab

Create a simple 2D fighting game in Python that runs within Google Colab. Specifications: - Game flow: start screen > fight scene > score display. - Controls: Use joystick-like controls implemented via keyboard keys. - Movement keys: left and right arrow keys or 'A' and 'D' keys. - Jump button: spacebar. - Fight buttons: one or two keys (e.g., 'J' for punch, 'K' for kick). - Gameplay: Two fighters facing each other with basic movements, jumping, and fighting actions. - Scoring: Track hits or rounds won and display the score after the fight. Considerations for Google Colab: - Since Google Colab does not support real-time interactive game windows, implement the game using a library that supports rendering in Colab, such as Pygame running with the 'nbgame' wrapper or using inline rendering with matplotlib or IPython display. - Use keyboard input simulation or capture inputs appropriately within Colab limitations. - Provide clear instructions within the code to run and interact with the game in Colab. # Steps 1. Setup the Colab environment to support Pygame or a compatible rendering framework. 2. Define the start screen with instructions and await user input to begin. 3. Implement fighter characters with movement (left/right), jumping, and fighting moves triggered by the specified keys. 4. Manage simple collision detection and hit registration. 5. Keep track of score based on hits or rounds. 6. Show the score screen after the fight ends. 7. Allow restarting or exiting. # Output Format Provide the complete Python code as a code block suitable for running in Google Colab, including setup commands (e.g., installing necessary packages), and comments explaining key sections. # Notes - The game should be minimal but functional within Colab's limitations. - Consider using inline frame-by-frame rendering or alternative display methods since real-time keyboard input is limited. - Include fallback instructions if real-time input is not feasible, e.g., turn-based input via prompts. # Example ```python # Sample code snippet illustrating capturing key events or rendering a frame in Colab ```

1-Minute Trading Script

Create a trading script tailored for executing buy and sell orders on a 1-minute chart based on the provided documentation. # Steps 1. **Visit the Documentation**: Access the given link to thoroughly understand the scripting environment and its capabilities. Carefully examine relevant sections to extract necessary details. 2. **Identify Key Concepts**: Extract essential syntax, functions, indicators, and examples pertinent for constructing a simple buy/sell algorithm. 3. **Draft the Script**: - Initialize the environment to process a 1-minute timeframe. - Implement basic market indicators to form decisions for buy and sell commands, such as moving averages, RSI, or price crossovers. - Design the script to effectively process real-time data inputs. 4. **Testing and Optimization**: - Verify adherence to the best practices highlighted in the documentation. - Test the script rigorously to ensure operational correctness and efficiency. Implement refinements based on testing outcomes. # Output Format - Start with a comment block summarizing the script's purpose and high-level operation. - Leverage appropriate syntax extracted from the documentation to construct the script code. - Add supportive comments throughout the code for enhanced understandability and maintenance. # Example ```javascript // Trading script for 1-minute buy/sell decisions // Implements a simple moving average crossover strategy // Utilizing real-time market data ... ``` # Notes - If specific indicators or conditions are mentioned in the documentation, integrate these into your script design. - Stay aligned with any legal or regulatory requirements stipulated by market exchanges, as mentioned in the documentation. - Incorporate robust exception handling and logging to ensure the script is resilient and easy to diagnose in real-world conditions.

Page 10 of 68

    Coding Prompts - Learning AI Prompts | Elevato