Skip to content

ommann/curvy-love2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Curvy

Curvy is a module for creating curve objects in Lua.

Curvy was initially created for creating video games, but can work in another context.

Usage

Curve objects are best thought as an interace for strictly ascending or descending line diagrams.

Curve objects are initialized with two tables given as arguments. First table represents the x-values and the second corresponding y-values.

Make sure each x-value has y-value. X-values must be strictly increasing. Y-values can be strictly increasing or decreasing.

--From 0 to 100 it takes 0.8 seconds
acceleration = curve( {0, 0.8, 2}, {0, 100, 200} )

Curve objects take two arguments:

  • y-value that is used as a starting spot
  • positive or negative adjustment value
--From the speed of 25 we further accelerate for a second
speed = acceleration(25, 1) --~128.6

Full example

curve = require 'curvy'

--From 0 to 100 it takes 0.8 seconds
acceleration = curve( {0, 0.8, 2.20}, {0, 100, 200} )

--From the speed of 25 we further accelerate for a second
speed1 = acceleration(25, 1) --~128.6

--From the speed of 0 we accelerate for 1 second
speed2 = acceleration(0, 1) --~114.3

print(speed1, speed2)

About

Module for creating curve objects for love2d.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages