Skip to content

Instantly share code, notes, and snippets.

@ChristopherKing42
Created November 12, 2015 17:20
Show Gist options
  • Select an option

  • Save ChristopherKing42/0120a7beb74dbc6fc0d3 to your computer and use it in GitHub Desktop.

Select an option

Save ChristopherKing42/0120a7beb74dbc6fc0d3 to your computer and use it in GitHub Desktop.
import Graphics.Gloss.Interface.Pure.Game
import Graphics.Gloss.Data.Bitmap
import Data.Monoid
history = 10
cr = green
mult = -1/3
main = loadBMP "explosion4.bmp" >>= \explosion -> play
(InWindow "Velocity" (500,500) (0,0))
black
120
((0,0), replicate history ((0,0),1), 10)
(\w@(p@(px,py),l,et) -> let ((xf, yf),_) = head l in let ((xi,yi),_) = last l in let t = sum $ tail $ map snd l in color cr $ Line [p, (px + mult*(xf-xi)/t, py + mult*(yf-yi)/t)] <> (if et < 1 then translate px py explosion else mempty))
(\e w@(p,l,et) -> case e of
EventMotion p' -> (p',l,et)
EventKey (MouseButton _) Up _ p' -> (p', l, 0)
_ -> w
)
(\t (p,l,et) -> (p,(p,t):(init l),et+t))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment