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_offset_y = 80,
|
||||||
block_gap = 5,
|
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
|
-- represenets the player-controlled paddle
|
||||||
@ -24,15 +24,14 @@ Player = {
|
|||||||
-- Returns 2 values, x and y!
|
-- Returns 2 values, x and y!
|
||||||
getCenter = function()
|
getCenter = function()
|
||||||
return Player.x + Player.width / 2, Player.y + Player.height / 2
|
return Player.x + Player.width / 2, Player.y + Player.height / 2
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Game = {
|
Game = {
|
||||||
ball = {
|
ball = {
|
||||||
position = { x = 0, y = 0 },
|
position = { x = 0, y = 0 },
|
||||||
velocity = { dx = 0, dy = 0 },
|
velocity = { dx = 0, dy = 0 },
|
||||||
radius = 5
|
radius = 5,
|
||||||
},
|
},
|
||||||
score = 0,
|
score = 0,
|
||||||
-- Array of breakable blocks, generated on load!
|
-- 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_wall = love.audio.newSource("impact_wall.ogg", "static")
|
||||||
Assets.impact_player = love.audio.newSource("impact_player.ogg", "static")
|
Assets.impact_player = love.audio.newSource("impact_player.ogg", "static")
|
||||||
|
|
||||||
|
love.window.setTitle("Breakout")
|
||||||
|
|
||||||
setupGame()
|
setupGame()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,7 +97,6 @@ function love.update()
|
|||||||
Game.ball.velocity.dx = (distance_from_center / (Player.width / 2)) * Settings.ball_speed
|
Game.ball.velocity.dx = (distance_from_center / (Player.width / 2)) * Settings.ball_speed
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Check box collisions
|
-- Check box collisions
|
||||||
for _, block in ipairs(Game.blocks) do
|
for _, block in ipairs(Game.blocks) do
|
||||||
if block.active then
|
if block.active then
|
||||||
@ -136,12 +136,12 @@ function love.draw()
|
|||||||
love.graphics.setColor(0, 0, 0, 1)
|
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("YOU WON! GOOD JOB!", love.graphics.getWidth() / 2, love.graphics.getHeight() / 2)
|
||||||
love.graphics.print(
|
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.setColor(255, 255, 255, 255) -- white?
|
||||||
love.graphics.draw(Assets.jirka,
|
love.graphics.draw(Assets.jirka, (love.graphics.getWidth() / 2) - 150, (love.graphics.getHeight() / 2) - 70)
|
||||||
(love.graphics.getWidth() / 2) - 150,
|
|
||||||
(love.graphics.getHeight() / 2) - 70)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -231,9 +231,9 @@ function setupGame()
|
|||||||
color = {
|
color = {
|
||||||
r = math.max(love.math.random(), 0.2),
|
r = math.max(love.math.random(), 0.2),
|
||||||
g = 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
|
cur_x = cur_x + block_width + gap
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user