Skip to content

Commit

Permalink
Added deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
29cmb committed Jul 28, 2024
1 parent d62e6bf commit 7c41c8d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 12 deletions.
53 changes: 44 additions & 9 deletions editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,22 @@ function editor:Load()
placeMode = "win"
end
},
["Delete"] = {
["Sprite"] = Sprites.DeleteButton,
["Transform"] = {490, 10, 75, 75},
["IsVisible"] = function()
return true
end,
["Selected"] = function()
return placeMode == "delete"
end,
["Callback"] = function()
placeMode = "delete"
end
},
["Save"] = {
["Sprite"] = Sprites.SaveButton,
["Transform"] = {490, 10, 75, 75},
["Transform"] = {570, 10, 75, 75},
["IsVisible"] = function()
return true
end,
Expand All @@ -141,7 +154,8 @@ function editor:Load()
love.window.showMessageBox("Error", "You cannot save a level without an end flag!", "error")
end
end
}
},

}
self.IsLoaded = true
end
Expand Down Expand Up @@ -188,20 +202,23 @@ function editor:Draw()
end

for _,button in pairs(self.buttons) do
if button.Selected() then
love.graphics.setColor(0.8,0.8,0.8)
love.graphics.draw(button.Sprite, button.Transform[1], button.Transform[2])
love.graphics.setColor(1,1,1,1)
else
love.graphics.draw(button.Sprite, button.Transform[1], button.Transform[2])
if button.IsVisible() then
if button.Selected() then
love.graphics.setColor(0.8,0.8,0.8)
love.graphics.draw(button.Sprite, button.Transform[1], button.Transform[2])
love.graphics.setColor(1,1,1,1)
else
love.graphics.draw(button.Sprite, button.Transform[1], button.Transform[2])
end
end

end

if fileName ~= nil then
love.graphics.push()
love.graphics.setFont(fonts.ValentinySubtext)
love.graphics.setColor(0,0,0)
love.graphics.print(fileName, 575, 40)
love.graphics.printf(fileName, 190, 560, 600, "right")
love.graphics.setColor(1,1,1)
love.graphics.setFont(fonts.Valentiny)
love.graphics.pop()
Expand Down Expand Up @@ -271,6 +288,24 @@ function editor:MousePressed(x, y, button)
["X"] = x - self.CameraData.CameraX - 40,
["Y"] = y - self.CameraData.CameraY - 40,
}
elseif placeMode == "delete" then
for index, value in pairs(level.Platforms) do
if utils:CheckCollision(x - self.CameraData.CameraX, y - self.CameraData.CameraY, 1, 1, value.X, value.Y, value.W, value.H) then
table.remove(level.Platforms, index)
end
end

for index, value in pairs(level.Gates) do
if utils:CheckCollision(x - self.CameraData.CameraX, y - self.CameraData.CameraY, 1, 1, value.X, value.Y, value.W, value.H) then
table.remove(level.Gates, index)
end
end

for index, value in pairs(level.Hazards) do
if utils:CheckCollision(x - self.CameraData.CameraX, y - self.CameraData.CameraY, 1, 1, value.X, value.Y, value.W, value.H or 65) then
table.remove(level.Hazards, index)
end
end
end
end
end
Expand Down
Binary file added images/DeleteButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PauseMenu.psd
Binary file not shown.
3 changes: 1 addition & 2 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ function love.draw()
level:draw()
player:draw()
pause:Draw()
end

end
end

function love.update(dt)
Expand Down
3 changes: 2 additions & 1 deletion modules/sprite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ local sprite = {
["EndFlag"] = "images/EndFlag.png",
["SaveButton"] = "images/SaveButton.png",
["MainMenu"] = "images/MainMenu.png",
["PauseMenu"] = "images/PauseMenu.png"
["PauseMenu"] = "images/PauseMenu.png",
["DeleteButton"] = "images/DeleteButton.png"
}
sprite.IsLoaded = false

Expand Down

0 comments on commit 7c41c8d

Please sign in to comment.