Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions test/etest.idr
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ data Vars = Position -- position of ellipse
-- generation and console I/O

Prog : Type -> Type -> Type
Prog i t = Eff IO [SDL i,
Position ::: STATE (Int, Int),
XMove ::: STATE Int,
YMove ::: STATE Int,
Frames ::: STATE Integer,
Starfield ::: STATE (List (Int, Int)),
RND,
STDIO] t
Prog i t = {[SDL i,
Position ::: STATE (Int, Int),
XMove ::: STATE Int,
YMove ::: STATE Int,
Frames ::: STATE Integer,
Starfield ::: STATE (List (Int, Int)),
RND,
STDIO]} Eff t

-- Convenient shorthand for initialised SDL
Running : Type -> Type
Running t = Prog SDLSurface t

initStarfield : List (Int, Int) -> Int -> Eff m [RND] (List (Int, Int))
initStarfield : List (Int, Int) -> Int -> { [RND] } Eff (List (Int, Int))
initStarfield acc 0 = return acc
initStarfield acc n = do x <- rndInt 0 639
y <- rndInt 0 479
initStarfield ((fromInteger x, fromInteger y) :: acc) (n - 1)

updateStarfield : List (Int, Int) -> Eff m [RND] (List (Int, Int))
updateStarfield : List (Int, Int) -> { [RND] } Eff (List (Int, Int))
updateStarfield xs = upd [] xs where
upd : List (Int, Int) -> List (Int, Int) -> Eff m [RND] (List (Int, Int))
upd : List (Int, Int) -> List (Int, Int) -> { [RND] } Eff (List (Int, Int))
upd acc [] = return acc
upd acc ((x, y) :: xs)
= if (y > 479) then do
Expand All @@ -56,7 +56,7 @@ updateStarfield xs = upd [] xs where
else
upd ((x, y+1) :: acc) xs

drawStarfield : List (Int, Int) -> Eff IO [SDL_ON] ()
drawStarfield : List (Int, Int) -> { [SDL_ON] } Eff ()
drawStarfield [] = return ()
drawStarfield ((x, y) :: xs) = do line white x y x y
drawStarfield xs
Expand Down Expand Up @@ -132,7 +132,7 @@ emain = do initialise 640 480
when continue eventLoop

main : IO ()
main = run [(), Position := (320,200),
main = runInit [(), Position := (320,200),
XMove := 0,
YMove := 0,
Frames := 0,
Expand Down