~qpfiffer/Voidcrash

d32b37e8da9accd64fdf36564f88bf4a41e4f7c0 — Quinlan Pfiffer 1 year, 10 months ago 35e9eb0
Navigation
M src/GameState.lua => src/GameState.lua +23 -6
@@ 25,6 25,7 @@ function GameState:key_pressed(key)
        love.event.quit()
    end
    if self:get_game_started() then
        -- TODO: Make this better.
        if key == "1" then
            self.current_state = self.active_states[1]
        elseif key == "2" then


@@ 96,18 97,34 @@ function GameState:get_game_started()
    return self.game_started
end

function GameState:_render_paused(renderer)
    if not self.paused then
        return
function GameState:_render_tabs(renderer)
    local accum = 1
    renderer:set_color("white")
    for i in pairs(self.active_states) do
        local is_active = false
        if self.active_states[i] == self.current_state then
            is_active = true
        end

        if i ~= 1 then
            accum = accum + renderer:draw_string("| ", constants.MAP_Y_MAX + 2, accum)
        end
        if is_active then
            renderer:set_color("red")
        end
        accum = accum + renderer:draw_string(self.active_states[i]:get_name() .. " ", constants.MAP_Y_MAX + 2, accum)
        renderer:set_color("white")
    end

    local middle_x = constants.MAP_X_MAX/2 - ((string.len("PAUSED") + 4) / 2)
    renderer:render_window_with_text(middle_x, constants.MAP_Y_MAX, "P")
    if self.paused then
        local middle_x = constants.MAP_X_MAX/2 - ((string.len("PAUSED") + 4) / 2)
        renderer:render_window_with_text(middle_x, constants.MAP_Y_MAX, "P")
    end
end

function GameState:render_current_state(renderer)
    self.current_state:render(renderer, self)
    self:_render_paused(renderer)
    self:_render_tabs(renderer)
end

function GameState:update_current_state(dt)

M src/states/FrameState.lua => src/states/FrameState.lua +4 -0
@@ 26,6 26,10 @@ function FrameState:init(next_state)
    return this
end

function FrameState:get_name()
    return "FRM"
end

function FrameState:key_pressed(game_state, key)
    if key == "up" then
        self.frame_selected_idx = self.frame_selected_idx - 1

M src/states/HullState.lua => src/states/HullState.lua +4 -0
@@ 26,6 26,10 @@ function HullState:init(next_state)
    return this
end

function HullState:get_name()
    return "HUL"
end

function HullState:key_pressed(game_state, key)
    if key == "right" then
        self.selected_idx = self.selected_idx + 1

M src/states/LatticeState.lua => src/states/LatticeState.lua +5 -1
@@ 42,6 42,10 @@ function LatticeState:init()
    return this
end

function LatticeState:get_name()
    return "LAT"
end

function LatticeState:_ensure_grid_size_selected(idx)
    if self.selected[idx] > LATTICE_GRID_SIZE then
        self.selected[idx] = 0


@@ 369,7 373,7 @@ function LatticeState:_render_lattice(renderer, game_state, connected)
    local height = renderer:getDrawAreaHeight()

    renderer:set_color("white")
    love.graphics.translate(width/2, height/16 - 150)
    love.graphics.translate(width/2, height/16 - 225)

    for x = 1, LATTICE_GRID_SIZE do
        for y = 1, LATTICE_GRID_SIZE + 1 do

M src/states/MapState.lua => src/states/MapState.lua +5 -0
@@ 57,6 57,11 @@ function MapState:init(game_state)
    return this
end

function MapState:get_name()
    return "MAP"
end


function MapState:_draw_breadcrumbs(renderer, player_info)
    -- Vector
    local accum = 1

M src/states/RadioState.lua => src/states/RadioState.lua +4 -0
@@ 20,6 20,10 @@ function RadioState:init(next_state)
    return this
end

function RadioState:get_name()
    return "RAD"
end

function RadioState:key_pressed(game_state, key)
end