From 6d7f6e7c9d2327acd7c5945cfad091c5cc13e011 Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Mon, 18 Oct 2010 13:02:45 +0200 Subject: [PATCH] Oscillator documentation/example --- index.html | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 6897b41..62ccafb 100644 --- a/index.html +++ b/index.html @@ -50,7 +50,7 @@ td, th { border-top: 1px dashed #ddd; } th { text-align: left; font-weight: normal; font-style: italic; text-decoration: underline; } td { padding-left: 1em; margin: 0; } - td.p { text-align: right; } + td.p { text-align: right; vertical-align: top; } .doc td em { font-size: .8em; font-weight:bold; font-style:normal; padding-right: .6em;} .doc pre, code { color: black; padding: 0; font-family: fixed; border: 1px solid #ddd; background: #e7ecec; } @@ -84,7 +84,7 @@ for the excellent LÖVE Engine.

  • timer.lua: timed function calling and interpolating functions,
  • vector.lua: a mature vector type,
  • class.lua: a simple and easy class system with function inheritance,
  • -
  • camera.lua: a translate-, zoom- and rotatable camera and
  • +
  • camera.lua: a move-, zoom- and rotatable camera and
  • ringbuffer.lua: a circular container.
  • sequence.lua: utility to handle ingame cutscenes and such.
  • @@ -227,6 +227,7 @@ module by clicking these: Timer.clear()Clear functions Timer.update(dt)Update timer Interpolator(length, func)Create interpolating function + Oscillator(length, func)Create interpolating function

    Note the . (dot) in the function names. It is an error to call Timer.add with a colon! If you get weird errors, that might be the cause.

    @@ -255,7 +256,7 @@ module by clicking these: Parameters:[number]delay: Time that has to pass before the function is called [function]func:The function to be called. - [optional number]count: + [optional number]count: Number of times the function should be called. If omitted, the function loops indefinitely. @@ -284,10 +285,30 @@ module by clicking these: will itself execute func with the right parameters. It returns true as long as the interpolation is not yet finished or nil if the interpolation stopped as well as any parameters that the function returns.

    +

    The prototype of the functions are:

    +

    - +
    Parameters:[number]length:Interpolation length.
    [function]func:Interpolating function.
    ReturnsA function inter(dt) with argument dt that has +
    ReturnsA function inter(dt, ...) that has + to be called in love.update.
    + + + +
    function Oscillator(length, func)^ top + Create oscillating function, i.e. a looped interpolating function. +

    The function does the same as Interpolator, except that if the passed time reaches length, + the internal timer will be reset. That means that the fraction-argument of the oscillating + function will loop from 0 to 1.

    +

    See the example for clarification

    + + + +
    Parameters:[number]length:Length of one period.
    [function]func:Oscillating function.
    ReturnsA function osc(dt, ...) that has to be called in love.update.
    @@ -330,9 +351,9 @@ end -
    Using Interpolator ^ top +
    Using Interpolator and Oscillator^ top This example uses an interpolating function to fade the background from black to white and - move a circle along the x-axis: + swings a circle around the screen center:
    function love.load()
         love.graphics.setBackgroundColor(0,0,0)
         love.graphics.setColor(0,0,0)
    @@ -340,7 +361,7 @@ end
     
     xpos = 100
     fader = Interpolator(5, function(frac) love.graphics.setBackgroundColor(frac*255,frac*255,frac*255) end)
    -mover = Interpolator(10, function(frac) xpos = 10 + 600 * frac end)
    +mover = Oscillator(10, function(frac) xpos = 400 + 300 * math.sin(2*math.pi*frac) end)
     function love.update(dt)
         fader(dt)
         mover(dt)
    @@ -657,7 +678,7 @@ result:foo()    -- error: method does not exist
    view source Depends on vector.lua

    Camera object to display only a partial region of the game world. The region - can be zoomed and rotated. You can transform camera coordinates to world coordinated + can be moved, zoomed and rotated. You can transform camera coordinates to world coordinated (e.g. get the location of the mouse in the game world). It is possible to have more than one camera per game.