Skip to content

MythicalMayhem/2d-physics-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2d lua physics engine

this project is built on LOVE 2d game engine, mainly just to hone skills but it is suitable for use

Run Locally

Install my-project with npm

  • create environment
    mkdir my-project
  • clone repo
    git clone https://github.com/MythicalMayhem/physicsNgine
  • install lua and make environment
  • install love 2d (how to install)
  •   cd my-project 
  • run with ALT + L

API Reference

objects

boxes

  boxes:new (canCollide,x,y,w,h,c)
(walls)
  • canCollide : collidable or walk-through
  • x,y : position
  • w,h : width / height
  • c : hitbox color {r,g,b,a} r,g,b,a in [0,1]

entities

  entities:new (x,y,w,h,c)
(walls)
  • canCollide : collidable or walk-through
  • x,y : position
  • w,h : hitbox width / height
  • c : hitbox color {r,g,b,a} r,g,b,a in [0,1]

forces

temporary impulse

  physics:applyImpulse(e,x,y,mag,res)
(jumping or knockback)
  • e : the entity (player or npc)
  • x,y : coordinates of the normalized vector
  • mag : magnitude
  • res : resistance, the rate of diminution

constant force

  physics:linear(e,x,y,mag)
(gravity or flying )
  • e : the entity (player or npc)
  • x,y : coordinates of the normalized vector
  • mag : magnitude

Tweening

create

local tw = tween:new(obj, { x = fromX, y = fromY }, { x = toX, y = toY }, seconds)

pause

tw:pause()

resume

tw:resume()

destroy

tw:destroy()

Acknowledgements

Authors

License

MIT

Usage/Examples

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages