Skip to content

Latest commit

 

History

History
42 lines (32 loc) · 1.55 KB

File metadata and controls

42 lines (32 loc) · 1.55 KB

Projectile Motion Simulator

A browser-based projectile motion simulator built with p5.js. Set a launch speed, angle, and gravitational acceleration to watch a ball follow its trajectory, then view the calculated range, time of flight, and maximum height.

Features

  • Adjustable launch speed (m/s) and angle (°)
  • Selectable gravitational acceleration: 9.8, 9.81, or 10 m/s²
  • Live preview line showing the launch angle before firing
  • Animated trajectory with trailing path
  • Results panel showing:
    • Time of flight
    • Range of the projectile
    • Maximum height reached
  • Reset button to reload and try again

Demo

Open index.html in a browser, or serve the folder with any static file server.

Getting Started

  1. Clone or download this repository.
  2. Open index.html directly in a web browser (double-click, or right-click → Open With).
  3. Enter a speed and angle in the input boxes.
  4. Choose a gravity value (9.8, 9.81, or 10).
  5. Click Start to launch the projectile.
  6. Click Reset to clear the simulation and try again.

No installation is required — the project relies on the p5.js library loaded via CDN.

Project Structure

Projectile-Motion-Simulator-main/
├── index.html      # Page structure and styling
├── setup.js        # p5.js setup, UI elements, and gravity controls
├── sketch.js        # Main draw loop, Ball class, and physics calculations
├── app.js          # Helper functions for UI button states
└── images/
    └── bg.jpg       # Background image