Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip #30

Merged
merged 4 commits into from
Dec 5, 2022
Merged

Wip #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Autarky2/Autarky2.love
Binary file not shown.
5 changes: 4 additions & 1 deletion Autarky2/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function constants.load()

TRANSLATEX = cf.round(SCREEN_WIDTH / 2) -- starts the camera in the middle of the ocean
TRANSLATEY = cf.round(SCREEN_HEIGHT / 2) -- need to round because this is working with pixels
ZOOMFACTOR = 1
ZOOMFACTOR = 0.95

GAME_LOG_DRAWX = SCREEN_WIDTH - 275
MAP = {}
Expand All @@ -25,6 +25,9 @@ function constants.load()
MOUSE_DOWN_X = nil
MOUSE_DOWN_Y = nil

MOUSE_DOWN_X = nil
MOUSE_DOWN_Y = nil

SCREEN_STACK = {}
IMAGES = {}
SPRITES = {}
Expand Down
67 changes: 36 additions & 31 deletions Autarky2/draw.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
draw = {}

function draw.topBar()
-- draw world hours
love.graphics.setColor(1,1,1,1)
local str = "Time: " .. WORLD_HOURS .. ":00 Day: " .. WORLD_DAYS .. " Treasury: $" .. TREASURY .. " "
if PAUSED then str = str .. "PAUSED" end
love.graphics.print(str, 10, 10)

-- draw villager counts
local occupationtable = people.getOccupationCount()
local str = "Farmers: " .. occupationtable[enum.jobFarmer] .. ". "
str = str .. "Healers: " .. occupationtable[enum.jobHealer] .. ". "
str = str .. "Woodsmen: " .. occupationtable[enum.jobWoodsman] .. ". "
str = str .. "Builders: " .. occupationtable[enum.jobBuilder] .. ". "
love.graphics.print(str, (SCREEN_WIDTH / 2) - 250, 10)

-- draw more counts on the far right margin
local str = "Villagers available: " .. #PERSONS .. " Villagers quit: " .. PERSONS_LEFT
love.graphics.print(str, SCREEN_WIDTH - 300, 10)

end

function draw.world()
-- draw the map including structures

Expand All @@ -12,8 +33,6 @@ function draw.world()

for col = 1, NUMBER_OF_COLS do
for row = 1, NUMBER_OF_ROWS do
-- drawx = LEFT_MARGIN + (col -1) * TILE_SIZE
-- drawy = TOP_MARGIN + (row - 1) * TILE_SIZE
local drawx, drawy = fun.getTileXY(row, col)

-- the grid border/outline
Expand Down Expand Up @@ -44,25 +63,6 @@ function draw.world()
end
end

-- draw world hours
love.graphics.setColor(1,1,1,1)
local str = "Time: " .. WORLD_HOURS .. ":00 Day: " .. WORLD_DAYS .. " Treasury: $" .. TREASURY .. " "
if PAUSED then str = str .. "PAUSED" end
love.graphics.print(str, 10, 10)

-- draw villager counts
local occupationtable = people.getOccupationCount()
local str = "Farmers: " .. occupationtable[enum.jobFarmer] .. ". "
str = str .. "Healers: " .. occupationtable[enum.jobHealer] .. ". "
str = str .. "Woodsmen: " .. occupationtable[enum.jobWoodsman] .. ". "
str = str .. "Builders: " .. occupationtable[enum.jobBuilder] .. ". "
love.graphics.print(str, (SCREEN_WIDTH / 2) - 250, 10)

-- draw more counts on the far right margin
local str = "Villagers available: " .. #PERSONS .. " Villagers quit: " .. PERSONS_LEFT
love.graphics.print(str, SCREEN_WIDTH - 300, 10)


end

function draw.daynight()
Expand Down Expand Up @@ -214,6 +214,8 @@ function draw.graphs()
local yvalue = drawy - HISTORY_PRICE[enum.stockHerbs][i]
love.graphics.points(drawx, yvalue)
end

love.graphics.print("Press ESCAPE to exit", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)
end

function draw.imageQueue()
Expand All @@ -235,22 +237,25 @@ function draw.imageQueue()
end

function draw.optionScreen()
tax_rate_up_button:show()
tax_rate_down_button:show()
close_options_button:show()
exit_game_button:hide()

love.graphics.setColor(1,1,1,1)
love.graphics.print(SALES_TAX, 300, 415)
-- tax_rate_up_button:show()
-- tax_rate_down_button:show()
-- close_options_button:show()
-- exit_game_button:hide()
--
-- love.graphics.setColor(1,1,1,1)
-- love.graphics.print(SALES_TAX, 300, 415)

love.graphics.print("Press ESCAPE to exit", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)

end

function draw.exitScreen()
function draw.exitScreen()
tax_rate_up_button:hide()
tax_rate_down_button:hide()
close_options_button:hide()

exit_game_button:show()
love.graphics.print("Press ENTER to exit", SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2)

end

return draw
2 changes: 2 additions & 0 deletions Autarky2/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ function functions.getTileXY(row, col)
end

function functions.getDrawXY(person)
-- returns the screen x/y
-- used to detect mouse interactions
local row = person.row
local col = person.col
local x = person.x
Expand Down
7 changes: 6 additions & 1 deletion Autarky2/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ function gui.load()
if SALES_TAX < 0 then SALES_TAX = 0 end
end

exit_game_button = gspot:button('Exit game', {x = 225, y = 400, w = 50, h = gspot.style.unit})
local y = SCREEN_HEIGHT / 2
local w = 100
local x = (SCREEN_WIDTH / 2) - (w / 2)

exit_game_button = gspot:button('Exit game', {x = x, y = y, w = w, h = gspot.style.unit * 2})

exit_game_button.click = function(this, x, y, button)
cf.RemoveScreen(SCREEN_STACK)
--! can invoke the 'quit' option here for safety
Expand Down
Loading