Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
49
Task/Animation/Lua/animation.lua
Normal file
49
Task/Animation/Lua/animation.lua
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
function love.load()
|
||||
text = "Hello World! "
|
||||
length = string.len(text)
|
||||
|
||||
|
||||
update_time = 0.3
|
||||
timer = 0
|
||||
right_direction = true
|
||||
|
||||
|
||||
local width, height = love.graphics.getDimensions( )
|
||||
|
||||
local size = 100
|
||||
local font = love.graphics.setNewFont( size )
|
||||
local twidth = font:getWidth( text )
|
||||
local theight = font:getHeight( )
|
||||
x = width/2 - twidth/2
|
||||
y = height/2-theight/2
|
||||
|
||||
end
|
||||
|
||||
|
||||
function love.update(dt)
|
||||
timer = timer + dt
|
||||
if timer > update_time then
|
||||
timer = timer - update_time
|
||||
if right_direction then
|
||||
text = string.sub(text, 2, length) .. string.sub(text, 1, 1)
|
||||
else
|
||||
text = string.sub(text, length, length) .. string.sub(text, 1, length-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function love.draw()
|
||||
love.graphics.print (text, x, y)
|
||||
end
|
||||
|
||||
function love.keypressed(key, scancode, isrepeat)
|
||||
if false then
|
||||
elseif key == "escape" then
|
||||
love.event.quit()
|
||||
end
|
||||
end
|
||||
|
||||
function love.mousepressed( x, y, button, istouch, presses )
|
||||
right_direction = not right_direction
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue