Skip to content
Browse files

Have arrow keys alter apparent direction of gravity.

This is a small change to the ball box demo.
Up arrow sets only a low upward pull, intentionally.
  • Loading branch information...
1 parent 7219ed3 commit cf7001693ca71b1ff2b2dfb4fab3369a86af0506 @nbogie committed
Showing with 5 additions and 0 deletions.
  1. +5 −0 Main.hs
View
5 Main.hs
@@ -86,6 +86,10 @@ main = do
case key of
Char 'c' -> clearSpace space balls
Char 'b' -> replicateM_ numNew (newBall space balls)
+ SpecialKey KeyLeft -> gravity space $= Vector (-0.7) (-0.7)
+ SpecialKey KeyDown -> gravity space $= Vector (-0.0) (-1)
+ SpecialKey KeyRight-> gravity space $= Vector ( 0.7) (-0.7)
+ SpecialKey KeyUp-> gravity space $= Vector 0 0.1
Char 'v' -> newBigBall space balls
Char 'f' -> toggleFPS fpsStat
Char '\27' -> leaveMainLoop
@@ -238,6 +242,7 @@ drawHelp = do
"Keys:"
, "b Spawn 10 balls"
, "v Spawn 1 big ball"
+ , "Arrows Gravity direction"
, "c clear box"
, "f Toggle FPS graph"
, "Escape Quit"

0 comments on commit cf70016

Please sign in to comment.
Something went wrong with that request. Please try again.