Skip to content

Instantly share code, notes, and snippets.

@kikito
Created May 8, 2011 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikito/961442 to your computer and use it in GitHub Desktop.
Save kikito/961442 to your computer and use it in GitHub Desktop.
tween demo (unfinished
tween = require 'tween'
function love.update(dt)
tween.update(dt)
end
local greenLight, yellowLight, redLight
trafficLight = { red={0,0,0}, green={0,0,0}, yellow={0,0,0} }
function greenLight()
tween(2, trafficLight, { green={0,255,0} }, yellowLight)
end)
function yellowLight()
tween(2, trafficLight, { yellow={255,255,0} }, redLight)
end)
function redLight()
tween(2, trafficLight, { red={255,0,0} }, greenLight)
end
function love.load()
-- text "falls down" from the top of the screen
label = { text = "Hello!", x = 200, y = -20 }
tween(2, label, { y = 300 }, 'outBounce')
-- box
-- * Moves from left to right, then fall down bouncing
-- * Doubles its width and height while moving to the right
-- * Changes the color from red to yellow, then to green
box = { x = 0, y = 300, color = { 255, 0, 0 }, width = 64, height = 64 }
tween(2, box, { x = 672, color = { 255, 255, 0}, width = 128, height = 128 }, 'inOutQuad', tween, 1, box, { y = 472, color = { 0, 255, 0 } }, 'outBounce')
-- traffic light
-- * iterates from
greeLight()
end
function love.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.print(label.text, label.x, label.y)
love.graphics.setColor(unpack(box.color))
love.graphics.rectangle('fill', box.x, box.y, box.width, box.height)
love.graphics.circle(fill
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment