43 lines
887 B
Lua
Raw Normal View History

2017-07-05 07:11:51 -07:00
require "keys"
-- Make this more functional. It shouldn't depend on global state.
function col_detect(object, display)
if not (object.x >= -1 and
object.x <= (display.width - object.width)) then
return false
end
if not (object.y >= -1 and
object.y <= (display.height - object.height)) then
return false
end
return true
end
function love.load()
saveFile = "test.lua"
-- Create a table and grab the screen width/height
screen = {}
screen.width = love.graphics.getWidth()
screen.height = love.graphics.getHeight()
-- Create a table to hold all the player data
player = {}
player.x = screen.width /2
player.y = screen.height - 50
2017-07-05 07:11:51 -07:00
player.width = 25
player.height = 5
player.speed = 5
end
function love.update(dt)
player = check_keys(player)
end
function love.draw()
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
end