reactive-banana

Performing a single switch in reactive-banana

荒凉一梦 提交于 2020-03-01 03:19:10
问题 I'm building a multi-modal editor using reactive-banana - and for the most part it's going perfect. To expand on my scenario, the editor is some mapping software, or you could think of it as a very simple vector graphics editor. It currently has two states - selection mode and polygon creation mode . In selection mode, the user is able to select previously created polygons with the right mouse button (which would in theory take you to a new selected mode ) or they can begin creating a new

SDL-Mixer audio stops upon starting Reactive-Banana input loop

我们两清 提交于 2020-01-14 22:52:43
问题 I've been working on a game that uses multiple audio tracks whose volumes are adjusted in realtime based on mouse motion. I'm using SDl-Mixer for audio, and Reactive-Banana for the game in general. The problem is that the tracks, which have all been started at the beginning, stop playing when the input-loop starts. The cause may be something else, but I wonder if there's some strange interaction between SDL and Reactive-Banana that I don't understand. I've been trying to puzzle this out for a

SDL-Mixer audio stops upon starting Reactive-Banana input loop

孤人 提交于 2020-01-14 22:51:33
问题 I've been working on a game that uses multiple audio tracks whose volumes are adjusted in realtime based on mouse motion. I'm using SDl-Mixer for audio, and Reactive-Banana for the game in general. The problem is that the tracks, which have all been started at the beginning, stop playing when the input-loop starts. The cause may be something else, but I wonder if there's some strange interaction between SDL and Reactive-Banana that I don't understand. I've been trying to puzzle this out for a

SDL-Mixer audio stops upon starting Reactive-Banana input loop

♀尐吖头ヾ 提交于 2020-01-14 22:51:27
问题 I've been working on a game that uses multiple audio tracks whose volumes are adjusted in realtime based on mouse motion. I'm using SDl-Mixer for audio, and Reactive-Banana for the game in general. The problem is that the tracks, which have all been started at the beginning, stop playing when the input-loop starts. The cause may be something else, but I wonder if there's some strange interaction between SDL and Reactive-Banana that I don't understand. I've been trying to puzzle this out for a

Why does `changes` return `Event t (Future a)`

邮差的信 提交于 2020-01-14 07:33:25
问题 The changes function has type Frameworks t => Behavior t a -> Moment t (Event t (Future a)) . Future is abstract and there is only one function that consumes it ( reactimate' ). However, I can easily write the following function: changes' :: Frameworks t => Behavior t a -> Moment t (Event t a) changes' b = fmap (fmap const b <@>) (changes b) to get a normal (non- Future ) event. Is something wrong with that function? If not, why does the original changes function have a more restrictive type?

Why should we use Behavior in FRP

五迷三道 提交于 2020-01-12 07:17:27
问题 I am learning reactive-banana. In order to understand the library I have decide to implement a dummy application that would increase a counter whenever someone pushes a button. The UI library I am using is Gtk but that is not relevant for the explanation. Here is the very simple implementation that I have come up with: import Graphics.UI.Gtk import Reactive.Banana import Reactive.Banana.Frameworks makeNetworkDescription addEvent = do eClick <- fromAddHandler addEvent reactimate $ (putStrLn .

reactive-banana time delays

帅比萌擦擦* 提交于 2020-01-12 05:27:06
问题 I have scoured the documentation of reactive-banana, and I can't find a way to specify explicit time delays. Say, for example, I would like to take an Event t a and shift all of its occurrences 1 second into the future; or get an event that fires 1 second from now (within Moment t ); or anything like that. Are explicit delays representable in reactive-banana? If not, how do users implement, e.g., echoing input delayed by a second? 回答1: As Ben indicates, this is correct: reactive-banana is no

Functional Banana Traveller - Input Handling

こ雲淡風輕ζ 提交于 2019-12-25 03:26:33
问题 This is a sub-problem from my Traveller project. I've put together the rudementary code that will handle input. It works, until I introduce a TChan to the mix. Below is the working code, with an example of how to use it. Then, I will change it and explain why I am doing so. Then, I'll talk about the problem. {-# LANGUAGE ScopedTypeVariables #-} import Control.Monad (forever) import Control.Concurrent (forkIO) import Control.Monad.STM (STM,atomically) import Control.Concurrent.STM.TChan import

How to create monadic behaviour in reactive-banana

风格不统一 提交于 2019-12-24 12:46:24
问题 Suppose I catch key presses and manipulate a code buffer accordingly: let bCode = accumB emptyCode eModifications eCodeChanges <- changes bCode I would like to create another behaviour bEval bEval = accumB freshEnv (magic eCodeChanges) which maps any state of code to its evaluation (triggered only when something really changes). However, evaluation happens in a monad Interpreter (think hint from hackage). Can I actually define such a behaviour bEval ? I guess I could just drag Interpreter

How to make a player jump (set it's y velocity)?

﹥>﹥吖頭↗ 提交于 2019-12-23 02:09:06
问题 Given the following: integralB :: Num a => Behavior t a -> Behavior t a -- definite integral of a behaviour eJump :: Event t a -- tells the player to jump bYAccel = pure 4000 -- y acceleration bYVel = integralB bYAccel -- y velocity bY = integralB bYVel -- y position How do I make the player jump (probably by setting its y velocity) when a jump event arrives? 回答1: You'll need to be able to apply an impulse to the Y velocity for the jump. From your own answer, you've come up with a way to do