Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Moonring

A Retro, Ultima-inspired RPG with modern design sensibilities! · By Fluttermind, bbbscarter

Android port!!!! :3

A topic by Gunroar created Oct 06, 2023 Views: 2,007 Replies: 8
Viewing posts 1 to 6
(+1)

Hey, Fluttermind, I don’t know if you remember me but I was one of the first people who replied to your topic when you release Moonring back in 2021 (or 2020? I don’t remember :P).

Glad to see the game is getting more well known (especially with a small engine like Love2d :D).

Anyway, if you remember back then I talked some unreasonable things about an android port XD. But the game had to much typinis what you said (+shaders and it would run slower on android). (Of course I mean for tablets, because phones may be too small.)

Well yesterday, after remembering the game, I was so desperate to try it even though my PC had been broken for a while, that I downloaded it and tried to run it on Love for android! :P

After opening with your game (I hope that’s okay for now, heheh. No distribution of course) I messed keypressed to translate to keyboard.isDown and disabling shaders + forcing the game to ignore some errors I didn’t understand (line 16600, dang. 😅) I got it to run!!!! (Nice work with the mouse support! :D). I can fight and lose a game and move around and even shout when insane!

Anyway it still has a lot of bugs, but I love the aesthetics. I wish you could release a .love file version that just fixes a few stuff for a touchscreen device (like entering downstairs and map gen stuff).

Images :)

Hello, I wanted to see if moonring got a android port and I found this post, could you tell me how did you manage to run It using love2d? I tried both the Steam and itch.io versions of the Game and I always get a error on launch. Löve also asks for a main.lua file but there is no such file on both versions. Thanks :) 

Heheh…it’s a very …very …long and complicated method that requires lua knowledge :). And it also crashes a lot. I just wish the creator would just make an official version :(

(2 edits)

In the latest version, I only need to hack the shader compilation to get the game running on Android. No slowdown experienced, just some weird mouse controlls.


-- Patch: Transpile to OpenGL ES shaders.
-- * Convert "extern Type var = initializer;" to "extern Type var;"
--    and send the initializer on load.
-- * Convert "1" to "1.0" unless in array subscriptions like "a[1]".
do
    local function load_if_looks_like_filename(code) --> code
        if code == nil then return nil end
        if code:match("[\n;]") then  -- looks like code, not path
            return code
        else  -- looks like path, not code
            -- The parenthesis are important, it keeps only
            -- the first result of love.filesystem.read(),
            -- which returns 2 results.
            return (love.filesystem.read(code))
        end
    end
    local function extract_extern_variable_initializers_into(
        code, inits
    ) --> code
        if code == nil then return nil end
        -- Remove comments, but keeps the newline.
        code = code:gsub("//[^\n]*", "")
        -- Search for "extern <type> <var> = <initializer> ;"
        for var, initializer in
            code:gmatch("extern%s+%S+%s+(%S+)%s*=%s*([^;]+);")
        do
            inits[var] = initializer
        end
        -- Remove initializers.
        code = code:gsub("(extern%s+%S+%s+%S+)%s*=%s*([^;]+);", "%1;")
        return code
    end
    local function send_initializers(shader, inits)
        local sends = {}
        for var, initializer in pairs(inits) do
            table.insert(sends, ("send(%q, %s)"):format(var, initializer))
        end
        local sendcode = table.concat(sends, "\n")
        print("SEND\n", sendcode)
        local chunk = load(sendcode, "send shader initializers", "t", {
            send = function(...)
                shader:send(...)
            end,
            vec2 = function(a, b) return {a, b} end,
            vec3 = function(a, b, c) return {a, b, c} end,
            vec4 = function(a, b, c, d) return {a, b, c, d} end,
        })
        chunk()
    end
    local function various_hacks(code) --> code
        if code == nil then return nil end
        -- Convert int literals to float literals.
        -- * Keep literals like "1.", "1.2" and ".2" intact,
        --    but replace "1" with "1.0".
        -- * Should also keep indexing literals like "a[1]" as integers.
        code = code
            :gsub("(%f[a-zA-Z0-9_:.][0-9]+%f[^0-9.])", "%1.0")
            :gsub("%[%s*([0-9]+)[.]0%s*%]", "[%1]")
        return code
    end
    local love_new_shader = love.graphics.newShader
    function love.graphics.newShader(pixelcode, vertexcode)
        pixelcode = load_if_looks_like_filename(pixelcode)
        vertexcode = load_if_looks_like_filename(vertexcode)
        pixelcode = various_hacks(pixelcode)
        vertexcode = various_hacks(vertexcode)
        local inits = {}
        pixelcode =
            extract_extern_variable_initializers_into(pixelcode, inits)
        vertexcode =
            extract_extern_variable_initializers_into(vertexcode, inits)
        local shader = love_new_shader(pixelcode, vertexcode)
        send_initializers(shader, inits)
        return shader
    end
end

Niiiiiccccce.

Back after a while, mine didn’t work out so well. Is it supposed to be in a playable state in terms of the controls?

(1 edit) (+1)

+1 I would love an Android port of Moonring!

+2

This looks like a fun game to play before sleep