mike: Added stupid stuff
This commit is contained in:
parent
47d1c9192e
commit
80a67f16b9
@ -71,11 +71,18 @@ function ball_bounce(player, ball, dt)
|
|||||||
ball.x_speed = ball.x_speed * -1
|
ball.x_speed = ball.x_speed * -1
|
||||||
end
|
end
|
||||||
|
|
||||||
--If ball hits screen top/bottom
|
--If ball hits screen top
|
||||||
if ball.y >= screen.height or ball.y <0 then
|
if ball.y >= screen.height then
|
||||||
|
ball.y_speed = ball.y_speed * -1
|
||||||
|
ball.score = ball.score + 1
|
||||||
|
end
|
||||||
|
--If ball hits screen bottom
|
||||||
|
if ball.y <= 0 then
|
||||||
ball.y_speed = ball.y_speed * -1
|
ball.y_speed = ball.y_speed * -1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--If ball hits paddle
|
--If ball hits paddle
|
||||||
|
|
||||||
if hitbox_collision(ball.x, ball.y, ball.width, ball.height,
|
if hitbox_collision(ball.x, ball.y, ball.width, ball.height,
|
||||||
|
@ -15,16 +15,20 @@ function love.load()
|
|||||||
-- Create a table to hold all the player data
|
-- Create a table to hold all the player data
|
||||||
actors.player = create_object(screen.width /2, screen.height - 50, 30, 5, 500)
|
actors.player = create_object(screen.width /2, screen.height - 50, 30, 5, 500)
|
||||||
-- Create a table to hold ball data
|
-- Create a table to hold ball data
|
||||||
actors.ball = create_object(screen.width /2, screen.height /2, 5, 10, 600)
|
actors.ball = create_object(screen.width /2, screen.height /2, 5, 5, 600)
|
||||||
actors.ball.x_speed = (actors.ball.speed /2)
|
actors.ball.x_speed = (-actors.ball.speed /2)
|
||||||
actors.ball.y_speed = (actors.ball.speed /2)
|
actors.ball.y_speed = (-actors.ball.speed /2)
|
||||||
|
actors.ball.score = 0
|
||||||
|
|
||||||
|
|
||||||
|
actors.start = love.timer.getTime()
|
||||||
|
local end_timer = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
actors.player = check_keys(actors.player, screen, dt)
|
actors.player = check_keys(actors.player, screen, dt)
|
||||||
actors.ball = ball_bounce(actors.player, actors.ball, dt)
|
actors.ball = ball_bounce(actors.player, actors.ball, dt)
|
||||||
|
end_timer = love.timer.getTime() - actors.start
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
@ -37,5 +41,13 @@ function love.draw()
|
|||||||
love.graphics.circle("line", actors.ball.x, actors.ball.y,
|
love.graphics.circle("line", actors.ball.x, actors.ball.y,
|
||||||
actors.ball.width, actors.ball.height)
|
actors.ball.width, actors.ball.height)
|
||||||
--FPS counter
|
--FPS counter
|
||||||
|
love.graphics.setColor(128,72,25)
|
||||||
love.graphics.print("FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
love.graphics.print("FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
||||||
|
--Ball Score
|
||||||
|
love.graphics.setColor(255,0,0)
|
||||||
|
love.graphics.print("Score: "..actors.ball.score, screen.width -80, 10)
|
||||||
|
--Timer
|
||||||
|
love.graphics.setColor(125,42,19)
|
||||||
|
love.graphics.print(string.format("Time M: %.2f", end_timer/60), screen.width -85, 50)
|
||||||
|
love.graphics.print(string.format("Time S: %.2f", end_timer), screen.width -85, 30)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user