Implement bullet trajectories using attachable items

This commit is contained in:
2024-09-29 21:51:14 +01:00
parent 88c3e02459
commit 4545caa7e6
26 changed files with 504 additions and 570 deletions
+26 -1
View File
@@ -1,4 +1,6 @@
module ShortShow where
module ShortShow
( shortShow
) where
import Geometry
--import Data.Typeable
@@ -13,5 +15,28 @@ instance ShortShow a => ShortShow (V2 a) where
instance ShortShow Float where
shortShow x = showFFloat (Just 2) x ""
instance ShortShow Int where
shortShow x
| x < k = show x
| x < m = fdiv x k "K"
| x < g = fdiv x m "M"
| x < t = fdiv x g "G"
| x < p = fdiv x t "T"
| otherwise = show x ++ "P"
fdiv :: Int -> Int -> String -> String
fdiv x y s = removeDot (take 3 (show ((fromIntegral x / fromIntegral y)::Float))) ++ s
removeDot :: String -> String
removeDot (a:b:'.':[]) = a:b:[]
removeDot xs = xs
k,m,g,t,p :: Int
k = 10 ^ (3 :: Int)
m = 10 ^ (6 :: Int)
g = 10 ^ (9 :: Int)
t = 10 ^ (12:: Int)
p = 10 ^ (15:: Int)
instance (ShortShow a,ShortShow b) => ShortShow (a,b) where
shortShow (a,b) = '(' : shortShow a ++ "," ++ shortShow b ++ ")"