Compare commits
No commits in common. "123885b2b3c49cc45a51ad6bce00a0d93f0c0933" and "331aefb0f6dadf9e17d07b3644899dd3fa82c060" have entirely different histories.
123885b2b3
...
331aefb0f6
@ -1,3 +1,5 @@
|
|||||||
|
local utils = require "lib.utils.utils"
|
||||||
|
|
||||||
--- @alias Device "mouse" | "key" | "pad"
|
--- @alias Device "mouse" | "key" | "pad"
|
||||||
|
|
||||||
--- @param device Device
|
--- @param device Device
|
||||||
@ -25,12 +27,6 @@ controls.keymap = {
|
|||||||
local currentKeys = {}
|
local currentKeys = {}
|
||||||
local cachedKeys = {}
|
local cachedKeys = {}
|
||||||
|
|
||||||
--- @type number
|
|
||||||
controls.mouseWheelY = 0
|
|
||||||
love.wheelmoved = function(x, y)
|
|
||||||
controls.mouseWheelY = y
|
|
||||||
end
|
|
||||||
|
|
||||||
--- polling controls in O(n)
|
--- polling controls in O(n)
|
||||||
--- should be called at the beginning of every frame
|
--- should be called at the beginning of every frame
|
||||||
function controls:poll()
|
function controls:poll()
|
||||||
@ -54,7 +50,6 @@ function controls:cache()
|
|||||||
for k, v in pairs(currentKeys) do
|
for k, v in pairs(currentKeys) do
|
||||||
cachedKeys[k] = v
|
cachedKeys[k] = v
|
||||||
end
|
end
|
||||||
controls.mouseWheelY = 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- marks a control consumed for the current frame
|
--- marks a control consumed for the current frame
|
||||||
|
|||||||
@ -30,6 +30,12 @@ camera.scale = camera:getDefaultScale()
|
|||||||
|
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
|
love.wheelmoved = function(x, y)
|
||||||
|
if camera.scale > camera:getDefaultScale() * 5 and y > 0 then return end;
|
||||||
|
if camera.scale < camera:getDefaultScale() / 5 and y < 0 then return end;
|
||||||
|
camera.scale = camera.scale + (camera.scale * 0.1 * y)
|
||||||
|
end
|
||||||
|
|
||||||
local controlMap = {
|
local controlMap = {
|
||||||
cameraMoveUp = Vec3({ 0, -1 }),
|
cameraMoveUp = Vec3({ 0, -1 }),
|
||||||
cameraMoveLeft = Vec3({ -1 }),
|
cameraMoveLeft = Vec3({ -1 }),
|
||||||
@ -44,13 +50,6 @@ function camera:update(dt)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-------------------- зум на колесо ---------------------
|
|
||||||
local y = Tree.controls.mouseWheelY
|
|
||||||
if camera.scale > camera:getDefaultScale() * 5 and y > 0 then return end;
|
|
||||||
if camera.scale < camera:getDefaultScale() / 5 and y < 0 then return end;
|
|
||||||
camera.scale = camera.scale + (camera.scale * 0.1 * y)
|
|
||||||
--------------------------------------------------------
|
|
||||||
|
|
||||||
local ps = Tree.panning
|
local ps = Tree.panning
|
||||||
if ps.delta:length() > 0 then
|
if ps.delta:length() > 0 then
|
||||||
local worldDelta = ps.delta:scale(1 / (self.pixelsPerMeter * self.scale)):scale(dt):scale(self.speed)
|
local worldDelta = ps.delta:scale(1 / (self.pixelsPerMeter * self.scale)):scale(dt):scale(self.speed)
|
||||||
@ -104,7 +103,6 @@ function camera:animateTo(position, animationNode)
|
|||||||
self.animationNode = animationNode
|
self.animationNode = animationNode
|
||||||
self.animationEndPosition = position
|
self.animationEndPosition = position
|
||||||
self.animationBeginPosition = self.position
|
self.animationBeginPosition = self.position
|
||||||
self.velocity = Vec3 {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @return Camera
|
--- @return Camera
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user