I want to have a particle field in Yampa. The single particle should just move in a straight line, but depending on an angle given. That angle and movement speed changes depending on the player's speed and angle. I don't know how better to explain, I'm developing something similar to this game.
Anyway, my code for now looks like this:
star :: (Float, Float) -> SF (Float, Float) (Float, Float)
star p0 = proc (vel, a) -> do
rec
v <- integral -< vel *^ (cos a, sin a)
p <- clampS ^<< (p0 ^+^) ^<< integral -< v ^+^ p
returnA -< p
clampS s@(x, y) | x > 1 = (x-2, y)
| x < (-1) = (x+2, y)
| y > 1 = (x, y-2)
| y < (-1) = (x, y+2)
| otherwise = s
vel
is the current speed, a
is the current angle. But the particles move in, well, strange ways. (Full code here
Unfortunately, I am sure I am thinking in a wrong way, but I have not yet been able to figure out how to do that, especially how using integral
correctly.
Maybe someone can give me some hints.
With the little hint from @martingw, I was able to cook up this, which is quite what I was looking for:
star :: (Float, Float) -> SF (Float, Float) (Float, Float)
star p0 = proc (a, vel) -> do
let (vx,vy) = vel *^ (cos a, sin a)
p <- clampS ^<< (p0 ^+^) ^<< integral -< (-vx,vy)
returnA -< p
clampS (x, y) = (x `fMod` 800, y `fMod` 600)