Skip to content

Commit

Permalink
Fix documentation (#215)
Browse files Browse the repository at this point in the history
* Remove HTML line breaks from Unity Academy

* Use lists for documentation

* Use markdown bold syntax instead of HTML

* Reformat remaining items in Unity Academy

* Remove extraneous HTML line breaks

Partially cleans up Physics module documentation.

* Reformat Physics 2D documentation

* Fix Unity Academy functions documentation
  • Loading branch information
RichDom2185 authored Jun 22, 2023
1 parent f72e5a1 commit 813a8ee
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 178 deletions.
23 changes: 9 additions & 14 deletions src/bundles/physics_2d/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
/**
* 2D Phyiscs simulation module for Source Academy.
*
* A <b>vector</b> is defined by its coordinates (x and y). The 2D vector is used to
* A **vector** is defined by its coordinates (x and y). The 2D vector is used to
* represent direction, size, position, velocity and other physical attributes in
* the physics world. Vector manipulation and transformations between vector and array
* types are supported.
*
* <br>
*
* A <b>force</b> is defined by its direction (a vector), its magnitude, duration and
* A **force** is defined by its direction (a vector), its magnitude, duration and
* start time. A force is only actively applied if:
*
* ```
* diff > 0 && diff < duration, where diff is world time - start time
* ```
*
* <br>
*
* A <b>world</b> is the single physics world the module is based on.
* A **world** is the single physics world the module is based on.
*
* - `set_gravity` needs to be called once at the start of the program to initialize the world
* and set the gravity.
* - `make_ground` and `add_wall` are optional but recommended to be used to set boundaries
* in the world.
*
* <br>
* An **object** is initially defined in the add function by:
*
* An <b>object</b> is initially defined in the add function by:
* - shape: which add function was used (e.g. `add_box_object`)
* - position: initial position
* - velocity: initial velocity
Expand All @@ -34,27 +30,27 @@
* - isStatic (whether it is affected by physics)
*
* There are also additional attributes that can be set after an object has been added:
*
* - density: mass per area of object
* - friction: how much friction the object surface has
*
* There are two ways to apply a force on a given object:
*
* - `apply_force`: applies a force to an object at a given object
* - `apply_force_to_center`: applies a force to an object directly at its center
*
* Detection of collision and precise starting time are provided by:
*
* - `is_touching`
* - `impact_start_time`
*
* <br>
*
* After adding objects to the world, calling `update_world` will simulate the world.\
* The suggested time step is 1/60 (seconds).
*
* Visualization of the physics world can also be seen in the display tab.
*
* <br>
*
* The following example simulates a free fall of a circle object.
*
* ```
* import { set_gravity, make_vector, add_circle_object, update_world } from "physics_2d";
*
Expand All @@ -71,7 +67,6 @@
* update_world(1/60);
* }
* ```
* <br>
*
* @module physics_2d
* @author Muhammad Fikri Bin Abdul Kalam
Expand Down
Loading

0 comments on commit 813a8ee

Please sign in to comment.