I am working on an Asteroid game made in Haskell with Graphics.gloss. Now I have defined a datatype for the asteroids like this:
data Asteroid = Asteroid { asteroidPos:: Point,
asteroidVel :: Vector,
asteroidSize :: Float }
So that it has a Position defined by a point, a velocity defined by a vector and it's size. Now I want to know how I could write an instance of Random for this datatype so that a new asteroid appears at a random time, on a random place with a random velocity. Does anyone know how I can accomplish this?
Aucun commentaire:
Enregistrer un commentaire