limit click distance for activating actions
This commit is contained in:
parent
8fb71181c6
commit
e6c0c1ad70
1 changed files with 5 additions and 3 deletions
|
@ -237,9 +237,9 @@ movePlayer _ = return ()
|
||||||
playerInteract :: MouseMessage -> Affection UserData ()
|
playerInteract :: MouseMessage -> Affection UserData ()
|
||||||
playerInteract (MsgMouseButton _ _ SDL.Pressed _ SDL.ButtonRight _ m) = do
|
playerInteract (MsgMouseButton _ _ SDL.Pressed _ SDL.ButtonRight _ m) = do
|
||||||
ud <- getAffection
|
ud <- getAffection
|
||||||
(V2 rx ry) <- liftIO $ relativizeMouseCoords m
|
(V2 rx ry) <- liftIO $ (* V2 640 360) <$> relativizeMouseCoords m
|
||||||
let dr = (ry / sin (atan 0.5) / 2) + rx
|
let dr = ((ry / 32) / sin (atan 0.5) / 2) + (rx / 64)
|
||||||
dc = rx - (ry / sin (atan 0.5) / 2)
|
dc = (rx / 64) - ((ry / 32) / sin (atan 0.5) / 2)
|
||||||
(nws, relEnts) <- liftIO $ yieldSystemT (worldState ud) $ do
|
(nws, relEnts) <- liftIO $ yieldSystemT (worldState ud) $ do
|
||||||
emap allEnts $ do
|
emap allEnts $ do
|
||||||
with player
|
with player
|
||||||
|
@ -265,11 +265,13 @@ playerInteract (MsgMouseButton _ _ SDL.Pressed _ SDL.ButtonRight _ m) = do
|
||||||
ent <- queryEnt
|
ent <- queryEnt
|
||||||
if (fmap floor ppos == fmap floor pos' ||
|
if (fmap floor ppos == fmap floor pos' ||
|
||||||
fmap floor ppos == fmap floor pos' + rel) &&
|
fmap floor ppos == fmap floor pos' + rel) &&
|
||||||
|
fmap floor ppos + fmap floor (V2 dr dc) == fmap floor pos' &&
|
||||||
pdir == dir
|
pdir == dir
|
||||||
then return $ Just (otype, ent)
|
then return $ Just (otype, ent)
|
||||||
else return Nothing
|
else return Nothing
|
||||||
return (catMaybes mrelEnts)
|
return (catMaybes mrelEnts)
|
||||||
liftIO $ A.logIO A.Debug ("relEnts: " ++ show relEnts)
|
liftIO $ A.logIO A.Debug ("relEnts: " ++ show relEnts)
|
||||||
|
-- liftIO $ A.logIO A.Debug ("dV2: " ++ show (V2 dr dc))
|
||||||
putAffection ud
|
putAffection ud
|
||||||
{ worldState = nws
|
{ worldState = nws
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue