limit click distance for activating actions

This commit is contained in:
nek0 2018-08-05 04:05:35 +02:00
parent 8fb71181c6
commit e6c0c1ad70

View file

@ -237,9 +237,9 @@ movePlayer _ = return ()
playerInteract :: MouseMessage -> Affection UserData ()
playerInteract (MsgMouseButton _ _ SDL.Pressed _ SDL.ButtonRight _ m) = do
ud <- getAffection
(V2 rx ry) <- liftIO $ relativizeMouseCoords m
let dr = (ry / sin (atan 0.5) / 2) + rx
dc = rx - (ry / sin (atan 0.5) / 2)
(V2 rx ry) <- liftIO $ (* V2 640 360) <$> relativizeMouseCoords m
let dr = ((ry / 32) / sin (atan 0.5) / 2) + (rx / 64)
dc = (rx / 64) - ((ry / 32) / sin (atan 0.5) / 2)
(nws, relEnts) <- liftIO $ yieldSystemT (worldState ud) $ do
emap allEnts $ do
with player
@ -265,11 +265,13 @@ playerInteract (MsgMouseButton _ _ SDL.Pressed _ SDL.ButtonRight _ m) = do
ent <- queryEnt
if (fmap floor ppos == fmap floor pos' ||
fmap floor ppos == fmap floor pos' + rel) &&
fmap floor ppos + fmap floor (V2 dr dc) == fmap floor pos' &&
pdir == dir
then return $ Just (otype, ent)
else return Nothing
return (catMaybes mrelEnts)
liftIO $ A.logIO A.Debug ("relEnts: " ++ show relEnts)
-- liftIO $ A.logIO A.Debug ("dV2: " ++ show (V2 dr dc))
putAffection ud
{ worldState = nws
}