2017-07-05 07:22:58 -07:00
|
|
|
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)
|
2017-07-22 15:45:12 -07:00
|
|
|
-- 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)
|
2017-07-25 18:31:15 -07:00
|
|
|
ball.x_speed = (ball.speed /2)
|
|
|
|
ball.y_speed = (ball.speed /2)
|
2017-07-22 15:45:12 -07:00
|
|
|
|
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()
|
2017-07-25 18:45:06 -07:00
|
|
|
--Draw paddle
|
2017-07-05 07:11:51 -07:00
|
|
|
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
|
2017-07-25 18:45:06 -07:00
|
|
|
--Draw ball
|
2017-07-22 15:45:12 -07:00
|
|
|
love.graphics.rectangle("line", ball.x, ball.y, ball.width, ball.height)
|
2017-07-25 18:45:06 -07:00
|
|
|
--FPS counter
|
|
|
|
love.graphics.print("FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
2017-07-05 07:11:51 -07:00
|
|
|
end
|