Log In  
Follow
Captain_Man
[ :: Read More :: ]

Super duper early WIP monster fighting game. Literally only a menu that does nothing. Up and down to move the cursor.

I am mostly uploading right now to ask for help. If you open the game you'll see I have a little border drawn and am putting text inside of it. Is there any way to draw text in here more easily? The naive approach of printing each time leaves leftover text. My thought was to us rectfill but then the text doesn't print over it (despite calling print afterwards). I've put the relevant code below of what I'm using. My thought it to just use solid background (\#0 control code) but this would still mean I need to print over the full area each time (by padding).

This just seems like it would be something more textual games have run into before and I was wondering what the approach is.

Thanks!

function _draw()
    -- ...snip...
    draw_menu()
end

menu={"fight", "item", "run"}
selection=0

function draw_menu()
    local text=""
    for k,v in pairs(menu) do
        if selection==k-1 then
            text..="➡️"
        else
            text..="  "
        end
        text..=v.."\n"
    end
    textbox(8, 72, 112, 48, text)
end

    -- 8, 72, 112, 48 for full area
function textbox(x, y, w, h,
    text)
    --rectfill(x, y, x+w-1, y+h-1, 0)
    --[[rhs wrap based on absolute
    x, not offset from print call]]
    local num_chars =
        to_fake_hex_str(flr((x+w)/4))
    print("\#0\^r"..num_chars..text,
        x, y)
end

Cart #picomon-0 | 2022-08-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#116332 2022-08-26 18:59