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

[Mouse] Allow customizing screen to slab transforms #80

Closed
wants to merge 1 commit into from

Conversation

idbrii
Copy link
Contributor

@idbrii idbrii commented Mar 11, 2021

Fix #20.

Add function arg to customize screen to slab coordinates.

Improve interoperability with screen resizing libraries by allowing
users to specify a function to transform screen coordinates into game
coordinates.

For example, with Ulydev/push you could do:

local function get_push_mouse(x,y)
    local new_x,new_y = push:toGame(x,y)
    if new_x and new_y then
        return new_x,new_y
    end
    return x,y
end
local game_width, game_height, window_width, window_height = 800, 600, 1920, 1080
push:setupScreen(game_width, game_height, window_width, window_height)
Slab.Initialize(get_push_mouse, args)

Fix flamendless#20.

Add function arg to customize screen to slab coordinates.

Improve interoperability with screen resizing libraries by allowing
users to specify a function to transform screen coordinates into game
coordinates.

For example, with Ulydev/push you could do:

    local function get_push_mouse(x,y)
        local new_x,new_y = push:toGame(x,y)
        if new_x and new_y then
            return new_x,new_y
        end
        return x,y
    end
    local game_width, game_height, window_width, window_height = 800, 600, 1920, 1080
    push:setupScreen(game_width, game_height, window_width, window_height)
    Slab.Initialize(get_push_mouse, args)
@idbrii idbrii deleted the transform-point branch August 7, 2021 15:22
@idbrii idbrii restored the transform-point branch August 7, 2021 15:56
idbrii added a commit to idbrii/love-slab that referenced this pull request Aug 7, 2021
Fix flamendless#20. Related to flamendless#80.

The function arg to customize screen to slab coordinates isn't passed
from Slab.Initialize -- it only passes the input table.

Usage with push.lua:

    function love.load(args)
        local function get_push_mouse(x,y)
            local new_x,new_y = push:toGame(x,y)
            if new_x and new_y then
                return new_x,new_y
            end
            return x,y
        end
        local game_width, game_height, window_width, window_height = 320, 240, 1280, 720
        push:setupScreen(game_width, game_height, window_width, window_height)
        args.TransformPointToSlab = get_push_mouse
        Slab.Initialize(args)
    end

    function love.draw()
        push:start()
            Slab.Draw()
        push:finish()
    end
idbrii added a commit to idbrii/love-slab that referenced this pull request Aug 7, 2021
Fix flamendless#20. Related to flamendless#80.

5fb76d3 changed the order of arguments from flamendless#80, so nothing was ever
passed as TransformPointToSlab. Instead, pass it inside the args table
that probably jives better with how things are done in slab.

The function arg to customize screen to slab coordinates isn't passed
from Slab.Initialize -- it only passes the input table.

Usage with push.lua:

    function love.load(args)
        local function get_push_mouse(x,y)
            local new_x,new_y = push:toGame(x,y)
            if new_x and new_y then
                return new_x,new_y
            end
            return x,y
        end
        local game_width, game_height, window_width, window_height = 320, 240, 1280, 720
        push:setupScreen(game_width, game_height, window_width, window_height)
        args.TransformPointToSlab = get_push_mouse
        Slab.Initialize(args)
    end

    function love.draw()
        push:start()
            Slab.Draw()
        push:finish()
    end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Interoperate with Ulydev/push (mouse position override)
1 participant