Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Improve the API #4

Closed
z0w0 opened this issue Jul 16, 2013 · 6 comments
Closed

Improve the API #4

z0w0 opened this issue Jul 16, 2013 · 6 comments
Milestone

Comments

@z0w0
Copy link
Owner

z0w0 commented Jul 16, 2013

This is a general bug to organize efforts in the following areas:

  • Audio support
  • Timer and frame rate deltas
  • Animation support or examples for it
@veryrandomname
Copy link
Contributor

Do you want to use FRP.Elerea.Param to distribute the time deltas over the signals?
If not, this should do the trick,right?

getTicks :: SignalGen (Signal Int)
getTicks = effectful $ fromIntegral <$> SDL.getTicks

getDT :: SignalGen (Signal Int)
getDT = getTicks >>= \t -> (fmap . fmap) snd $ (transfer (0,0) (\t (lastT,lastDT) -> (t,t-lastT)) t )

edit:
I think it only works if the signal is sampled every frame, ie. the value of getDT is always used in the collage function. We would have to force it being used somehow, to make it always work.

main = run $ do
  dt <- getDT
  b <- booleanSignalGen
  if b        --just pretent its Bool istead of Signal Bool, because I'm too lazy.
    then
      return $ dummy <$> dt --dt is sampled correctly
    else
      return $ return $ dummy 0 --dt is not sampled now, lastT won't be updated, next dt will be wrong. 

dummy :: a -> Element
dummy a = collage 600 800 []

Should we do something about that?

I think it would be more reliable to calculate the time in the run' function and then distribute it with FRP.Elerea.Param.
Altough I don't like the extra parameter being forced on the user.
I will do that, if you think it makes sense design wise.

@z0w0
Copy link
Owner Author

z0w0 commented Jul 24, 2013

Looks good. I'll take a look tomorrow.

@z0w0
Copy link
Owner Author

z0w0 commented Jul 25, 2013

Sorry if I'm misinterpreting, but only having it work if it's sampled every frame is kind of the functionality I was hoping for. It's going to be called delta or something similar, so even if it wasn't used for frame deltas, it would make sense that it would return the passed time since last sample. Also I agree with regards to FRP.Elerea.Param, because I think the simple version is a lot, well, simpler. And I think it fits nicer with the Helm API how it is now.

@veryrandomname
Copy link
Contributor

Oh I didn't think about that! Its not a bug its a feature! Yeah sure. Giving control over what kind of deltas one can get is awesome. I also like the idea of an generic delta function. Not just for time.

@z0w0
Copy link
Owner Author

z0w0 commented Jul 25, 2013

@veryrandomname there's a prototype of a Time module now, with a delta function based on your code. I've added attribution in the AUTHORS file, let me know if you want more detailed attribution based on your real name or an email.

@z0w0
Copy link
Owner Author

z0w0 commented Jul 28, 2013

Frame rate handling and basic animations are now supported. See #11 about the audio API.

@z0w0 z0w0 closed this as completed Aug 20, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants