diff --git a/game/hammouse.gif b/game/hammouse.gif new file mode 100644 index 0000000..ccfc3e8 Binary files /dev/null and b/game/hammouse.gif differ diff --git a/game/hammouse.png b/game/hammouse.png new file mode 100644 index 0000000..eb31860 Binary files /dev/null and b/game/hammouse.png differ diff --git a/game/main.lua b/game/main.lua index e563296..3cc12db 100644 --- a/game/main.lua +++ b/game/main.lua @@ -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() @@ -18,10 +18,14 @@ function love.load() ttf = love.graphics.newFont() bf = love.graphics.newImageFont("font.png", - " abcdefghijklmnopqrstuvwxyz" .. - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0" .. - "123456789.,!?-+/():;%&`'*#=[]\"") - bfi = love.graphics.newImage("font.png") + " abcdefghijklmnopqrstuvwxyz" .. + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0" .. + "123456789.,!?-+/():;%&`'*#=[]\"") + 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 diff --git a/game/platform/native.lua b/game/platform/native.lua index e5fada3..5b9d639 100644 --- a/game/platform/native.lua +++ b/game/platform/native.lua @@ -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