Implemented the mouse scale patch on native platform
This commit is contained in:
parent
cf06bdce64
commit
01a000b9fa
4 changed files with 38 additions and 7 deletions
BIN
game/hammouse.gif
Normal file
BIN
game/hammouse.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 219 B |
BIN
game/hammouse.png
Normal file
BIN
game/hammouse.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 329 B |
|
|
@ -6,7 +6,7 @@ end
|
|||
local platform = require "platform.platform"
|
||||
local ttf
|
||||
local bf
|
||||
local bfi
|
||||
local hamsterMouse
|
||||
|
||||
local function drawText(str, x, y)
|
||||
local font = love.graphics.getFont()
|
||||
|
|
@ -21,7 +21,11 @@ function love.load()
|
|||
" abcdefghijklmnopqrstuvwxyz" ..
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0" ..
|
||||
"123456789.,!?-+/():;%&`'*#=[]\"")
|
||||
bfi = love.graphics.newImage("font.png")
|
||||
if love.system.getOS() == 'DOS' then
|
||||
hamsterMouse = love.graphics.newImage("hammouse.gif")
|
||||
else
|
||||
hamsterMouse = love.graphics.newImage("hammouse.png")
|
||||
end
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
|
@ -34,7 +38,8 @@ function love.draw()
|
|||
love.graphics.print(" abcdefghijklmnopqrstuvwxyz", 0, 110)
|
||||
love.graphics.print("ABCDEFGHIJKLMNOPQRSTUVWXYZ0", 0, 130)
|
||||
love.graphics.print("123456789.,!?-+/():;%&`'*#=[]\"", 0, 150)
|
||||
love.graphics.draw(bfi, 0, 170)
|
||||
|
||||
love.graphics.draw(hamsterMouse, love.mouse.getX(), love.mouse.getY())
|
||||
|
||||
platform.drawEnd()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local platform = {}
|
||||
local platform = { mouse = {} }
|
||||
|
||||
local screenWidth = 320
|
||||
local screenHeight = 200
|
||||
|
|
@ -8,6 +8,7 @@ local canvas
|
|||
function platform.init()
|
||||
love.graphics.setDefaultFilter("nearest")
|
||||
|
||||
love.graphics.setCanvas() -- Reset the canvas to avoid any bugs
|
||||
love.window.setMode(screenWidth * screenScale, screenHeight * screenScale, { resizable = false, vsync = true })
|
||||
canvas = love.graphics.newCanvas(screenWidth, screenHeight)
|
||||
end
|
||||
|
|
@ -21,4 +22,29 @@ function platform.drawEnd()
|
|||
love.graphics.draw(canvas, 0, 0, 0, screenScale, screenScale)
|
||||
end
|
||||
|
||||
local mouseGetX = function()
|
||||
return platform.mouse._ogMouseGetX() / screenScale
|
||||
end
|
||||
if mouseGetX ~= love.mouse.getX then
|
||||
platform.mouse._ogMouseGetX = love.mouse.getX
|
||||
love.mouse.getX = mouseGetX
|
||||
end
|
||||
|
||||
local mouseGetY = function()
|
||||
return platform.mouse._ogMouseGetY() / screenScale
|
||||
end
|
||||
if mouseGetY ~= love.mouse.getY then
|
||||
platform.mouse._ogMouseGetY = love.mouse.getY
|
||||
love.mouse.getY = mouseGetY
|
||||
end
|
||||
|
||||
local mouseGetPosition = function()
|
||||
local x, y = platform.mouse._ogMouseGetPosition()
|
||||
return x / screenScale, y / screenScale
|
||||
end
|
||||
if mouseGetPosition ~= love.mouse.getPosition then
|
||||
platform.mouse._ogMouseGetPosition = love.mouse.getPosition
|
||||
love.mouse.getPosition = mouseGetPosition
|
||||
end
|
||||
|
||||
return platform
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue