mike: Added function to create object; created bouncing ball

This commit is contained in:
2017-07-22 15:45:12 -07:00
parent 3953d079d6
commit 841c7a8706
2 changed files with 32 additions and 7 deletions

View File

@@ -10,20 +10,21 @@ function love.load()
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
player = create_object(screen.width /2, screen.height - 50, 25, 5, 10)
-- Create a table to hold ball data
ball = create_object(screen.width /2, screen.height /2, 1, 1, 5)
ball.x_speed = ball.speed /2
ball.y_speed = ball.speed /2
player.width = 25
player.height = 5
player.speed = 10
end
function love.update(dt)
player = check_keys(player)
ball = ball_bounce(ball)
end
function love.draw()
love.graphics.rectangle("line", player.x, player.y, player.width, player.height)
love.graphics.rectangle("line", ball.x, ball.y, ball.width, ball.height)
end