Skip to content

Instantly share code, notes, and snippets.

@ianfitzpatrick
Last active August 17, 2016 22:00
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 ianfitzpatrick/b6e4a71454e520a3d5f01f9a18e57290 to your computer and use it in GitHub Desktop.
Save ianfitzpatrick/b6e4a71454e520a3d5f01f9a18e57290 to your computer and use it in GitHub Desktop.
io.stdout:setvbuf('no')
debug = true
function love.load(arg)
love.window.setMode( 1280, 720)
bg = { x = 0, y = 0 }
bg.img = love.graphics.newImage('assets/graphics/backgrounds/football_field_bg.png')
love.graphics.setBackgroundColor( 0, 0, 0 )
scroll = {rate = 150, step = 800, counter = 0}
end
function love.update(dt)
-- require('lovebird').update()
-- Testing screen scrolling
if scroll.counter == 0 then
canscroll = true
else
canscroll = false
end
if love.keyboard.isDown('right') then
scroll.counter = scroll.counter + scroll.rate
if bg.x > -4480 and canscroll == true then
bg.x = bg.x - scroll.rate
end
end
if love.keyboard.isDown('left') then
scroll.counter = scroll.counter + scroll.rate
if bg.x < 0 and canscroll then
bg.x = bg.x + scroll.rate
end
end
if scroll.counter >= scroll.step then
scroll.counter = 0
end
end
function love.draw()
love.graphics.draw(bg.img, bg.x, bg.y)
love.graphics.print('canscroll ' .. scroll.counter, 50, 50)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment