mike: Added function to create object; created bouncing ball
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user