35 lines
940 B
Lua
Raw Normal View History

require "lib/keys"
require "lib/functions"
2017-07-05 07:11:51 -07:00
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
2017-07-25 18:41:25 -07:00
player = create_object(screen.width /2, screen.height - 50, 30, 5, 500)
-- Create a table to hold ball data
2017-07-25 18:41:25 -07:00
ball = create_object(screen.width /2, screen.height /2, 1, 1, 600)
ball.x_speed = (ball.speed /2)
ball.y_speed = (ball.speed /2)
2017-07-05 07:11:51 -07:00
end
function love.update(dt)
2017-07-25 18:41:25 -07:00
player = check_keys(player, screen, dt)
ball = ball_bounce(player, ball, dt)
2017-07-05 07:11:51 -07:00
end
2017-07-16 13:15:47 -07:00
2017-07-05 07:11:51 -07:00
function love.draw()
--Draw paddle
2017-07-05 07:11:51 -07:00
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
--Draw ball
love.graphics.rectangle("line", ball.x, ball.y, ball.width, ball.height)
--FPS counter
love.graphics.print("FPS: "..tostring(love.timer.getFPS( )), 10, 10)
2017-07-05 07:11:51 -07:00
end