Formatting
This commit is contained in:
parent
b33983318c
commit
65fab4710d
22
main.lua
22
main.lua
@ -10,7 +10,7 @@ Settings = {
|
||||
block_offset_y = 80,
|
||||
block_gap = 5,
|
||||
|
||||
collision_margin = 2 -- kinda tied to ball radius lol
|
||||
collision_margin = 2, -- kinda tied to ball radius lol
|
||||
}
|
||||
|
||||
-- represenets the player-controlled paddle
|
||||
@ -24,15 +24,14 @@ Player = {
|
||||
-- Returns 2 values, x and y!
|
||||
getCenter = function()
|
||||
return Player.x + Player.width / 2, Player.y + Player.height / 2
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
|
||||
Game = {
|
||||
ball = {
|
||||
position = { x = 0, y = 0 },
|
||||
velocity = { dx = 0, dy = 0 },
|
||||
radius = 5
|
||||
radius = 5,
|
||||
},
|
||||
score = 0,
|
||||
-- Array of breakable blocks, generated on load!
|
||||
@ -48,6 +47,8 @@ function love.load()
|
||||
Assets.impact_wall = love.audio.newSource("impact_wall.ogg", "static")
|
||||
Assets.impact_player = love.audio.newSource("impact_player.ogg", "static")
|
||||
|
||||
love.window.setTitle("Breakout")
|
||||
|
||||
setupGame()
|
||||
end
|
||||
|
||||
@ -96,7 +97,6 @@ function love.update()
|
||||
Game.ball.velocity.dx = (distance_from_center / (Player.width / 2)) * Settings.ball_speed
|
||||
end
|
||||
|
||||
|
||||
-- Check box collisions
|
||||
for _, block in ipairs(Game.blocks) do
|
||||
if block.active then
|
||||
@ -136,12 +136,12 @@ function love.draw()
|
||||
love.graphics.setColor(0, 0, 0, 1)
|
||||
love.graphics.print("YOU WON! GOOD JOB!", love.graphics.getWidth() / 2, love.graphics.getHeight() / 2)
|
||||
love.graphics.print(
|
||||
"Press space to play again", love.graphics.getWidth() / 2, (love.graphics.getHeight() / 2) + 30
|
||||
"Press space to play again",
|
||||
love.graphics.getWidth() / 2,
|
||||
(love.graphics.getHeight() / 2) + 30
|
||||
)
|
||||
love.graphics.setColor(255, 255, 255, 255) -- white?
|
||||
love.graphics.draw(Assets.jirka,
|
||||
(love.graphics.getWidth() / 2) - 150,
|
||||
(love.graphics.getHeight() / 2) - 70)
|
||||
love.graphics.draw(Assets.jirka, (love.graphics.getWidth() / 2) - 150, (love.graphics.getHeight() / 2) - 70)
|
||||
|
||||
return
|
||||
end
|
||||
@ -231,9 +231,9 @@ function setupGame()
|
||||
color = {
|
||||
r = math.max(love.math.random(), 0.2),
|
||||
g = math.max(love.math.random(), 0.2),
|
||||
b = math.max(love.math.random(), 0.2)
|
||||
b = math.max(love.math.random(), 0.2),
|
||||
},
|
||||
active = true -- This is turned off when a box is hit
|
||||
active = true, -- This is turned off when a box is hit
|
||||
})
|
||||
cur_x = cur_x + block_width + gap
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user