gravity/Main.hs

25 lines
727 B
Haskell

-- SPDX-License-Identifier: ISC
-- Copyright (c) 2020 Camden Dixie O'Brien
module Main (main) where
import Graphics.Gloss
import Graphics.Gloss.Geometry.Angle
data PolarCoord = PolarCoord { radius :: Float, angle :: Float }
render :: PolarCoord -> Picture
render state = pictures [ circleSolid 10, translatePolar state $ circleSolid 10 ]
step :: a -> b -> PolarCoord -> PolarCoord
step _ _ state = state { angle = normalizeAngle $ angle state + pi / 50 }
translatePolar :: PolarCoord -> Picture -> Picture
translatePolar q = rotate (radToDeg $ angle q) . translate (radius q) 0
window :: Display
window = InWindow "Foo" (200, 200) (100, 100)
main :: IO ()
main = simulate window white 100 (PolarCoord 80 0) render step