Skip to content

Commit

Permalink
Add showing building on hover of card.
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderv committed Apr 23, 2018
1 parent 885b5b4 commit 88bf09e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
5 changes: 5 additions & 0 deletions scripts/rendering/renderUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ end
R.drawBuilding = function(state)
local x, y = scripts.helpers.calculations.getCoordinatesFromScreenPosition(love.mouse.getPosition())
local b = scripts.helpers.calculations.hasBuilding(state, x, y)
if CAMERA.buildingFocus then

b = {building=CAMERA.buildingFocus}
end

if b then

love.graphics.setColor(1, 1, 1)
Expand Down
31 changes: 25 additions & 6 deletions scripts/states/showCard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,52 @@ function menu:draw(b)
love.graphics.scale(GLOBSCALE())
scripts.rendering.renderUI.drawCard(menu.state, menu.card)
if CANPLAY(menu.state, menu.card) then
love.graphics.draw(ICONS["button-ok"].image, 750, 500, 0, 0.25)
love.graphics.draw(ICONS["button-ok"].image, 750, 455, 0, 0.25)
end
love.graphics.draw(ICONS["button-cancel"].image, 710, 500, 0, 0.25)
love.graphics.draw(ICONS["button-trash"].image, 670, 500, 0, 0.25)
love.graphics.draw(ICONS["button-cancel"].image, 710, 455, 0, 0.25)
love.graphics.draw(ICONS["button-trash"].image, 670, 455, 0, 0.25)

love.graphics.pop()
end
end

function menu:update(dt, b)
local x, y = love.mouse.getPosition()
local xg, yg = x / GLOBSCALE(), y / GLOBSCALE()

if xg > 500 and xg < 800 and yg > 100 and yg < 500 then
local c = scripts.gameobjects.cards[STATE.hand[menu.card]]
if c.effects then
local building
for _, effect in pairs(c.effects) do
if effect.type == "place_building" then
building = effect.building
end
end
CAMERA.buildingFocus = building
end
else
CAMERA.buildingFocus = nil
end

menu.prev:update(dt, true)
end

function menu:mousepressed(x, y, mouse_btn)

if mouse_btn == 1 then
local xg, yg = x / GLOBSCALE(), y / GLOBSCALE()
if xg > 750 and xg < 790 and yg > 500 and yg < 540 then
if xg > 750 and xg < 790 and yg > 455 and yg < 495 then
startCard(STATE, menu.card, false)
end
if xg > 710 and xg < 750 and yg > 500 and yg < 540 then
if xg > 710 and xg < 750 and yg > 455 and yg < 495 then
Gamestate.pop()
end
if xg > 670 and xg < 710 and yg > 500 and yg < 540 then
if xg > 670 and xg < 710 and yg > 455 and yg < 495 then
table.remove(STATE.hand, menu.card)
Gamestate.pop()
end

local k = scripts.helpers.calculations.getCardNumber(x, y, true)
if k then
Gamestate.pop()
Expand Down

0 comments on commit 88bf09e

Please sign in to comment.