RoboCraft Prototype: Robot Navigator
Build a 2D simulation where a robot moves with arrow keys and avoids obstacles!
Project Overview
Goal: Create a web app simulating a robot navigating a 2D environment with obstacles.
Tasks:
- Add the p5.js library via CDN in the HTML tab.
- Draw a robot (e.g., rectangle) and obstacles (e.g., walls) using p5.js in the JavaScript tab.
- Implement arrow key controls to move the robot.
- Add collision detection to prevent the robot from passing through obstacles.
- Ensure the robot stays within canvas boundaries.
Skills Learned: JavaScript (movement logic), p5.js (graphics, input handling), simulation (collision detection, boundaries).
Get Started
Follow these steps to build your robot navigator:
- Plan: Sketch the environment (robot, obstacles, canvas size).
- Code: Use the OneCompiler editor below, starting from scratch.
- Add p5.js: In the OneCompiler HTML tab, add the p5.js library to enable canvas and drawing:
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.2/p5.min.js"></script>
- Draw: In the JavaScript tab, create a canvas and draw a robot and obstacles.
- Move: Add arrow key controls and collision detection.
- Learn: Visit the RoboCraft course on Xion Apex Academy for tutorials.
- Submit: Share your simulation URL for feedback.
Code Workspace
Write your robot navigator from scratch in the editor below. Use the HTML tab for the p5.js CDN and the JavaScript tab for simulation logic.
Prefer coding externally? Use Replit or Download Starter Files (includes empty HTML/JS files).
Submit Your Simulation
Once your robot navigator is ready, submit the URL (e.g., Replit or hosted link) for feedback or share it on Discord!