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
|
||||
end
|
||||
|
||||
--If ball hits screen top/bottom
|
||||
if ball.y >= screen.height or ball.y <0 then
|
||||
--If ball hits screen top
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
|
||||
--If ball hits paddle
|
||||
|
||||
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
|
||||
actors.player = create_object(screen.width /2, screen.height - 50, 30, 5, 500)
|
||||
-- Create a table to hold ball data
|
||||
actors.ball = create_object(screen.width /2, screen.height /2, 5, 10, 600)
|
||||
actors.ball.x_speed = (actors.ball.speed /2)
|
||||
actors.ball.y_speed = (actors.ball.speed /2)
|
||||
actors.ball = create_object(screen.width /2, screen.height /2, 5, 5, 600)
|
||||
actors.ball.x_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
|
||||
|
||||
function love.update(dt)
|
||||
actors.player = check_keys(actors.player, screen, dt)
|
||||
actors.ball = ball_bounce(actors.player, actors.ball, dt)
|
||||
end_timer = love.timer.getTime() - actors.start
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
@ -37,5 +41,13 @@ function love.draw()
|
||||
love.graphics.circle("line", actors.ball.x, actors.ball.y,
|
||||
actors.ball.width, actors.ball.height)
|
||||
--FPS counter
|
||||
love.graphics.setColor(128,72,25)
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user