From e6c0c1ad7058f90b505a930beee24561db973756 Mon Sep 17 00:00:00 2001 From: nek0 Date: Sun, 5 Aug 2018 04:05:35 +0200 Subject: [PATCH] limit click distance for activating actions --- src/MainGame/WorldMap.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/MainGame/WorldMap.hs b/src/MainGame/WorldMap.hs index a7bbab4..3d4e47c 100644 --- a/src/MainGame/WorldMap.hs +++ b/src/MainGame/WorldMap.hs @@ -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 }