turion / rhine

Haskell Functional Reactive Programming framework with type-level clocks
http://hackage.haskell.org/package/rhine
123 stars 21 forks source link

Add a loop or feedback SN constructor #181

Closed turion closed 2 years ago

turion commented 2 years ago

Thanks @SheetKey for inspiration

turion commented 2 years ago

@SheetKey can you have a look at the RandomWalk example and see whether the function feedbackRhine and the Loop constructor cover your use cases?

turion commented 2 years ago
turion commented 2 years ago
SheetKey commented 2 years ago

@turion its exactly what I was looking for! I'm using an ECS and using only ClSFs with feedback for my main game loop forced everything to happen on the same clock where I would rather have the ability to have different processes happen at different rates.

turion commented 2 years ago

That sounds great :) what's an ECS? In case your code is open, feel free to share.

SheetKey commented 2 years ago

Entity component system. You essentially treat every game object as a collection of components (mostly wrapped in Maybe), then define functions, in my case signal functions, that do things with the components. For example I have position and velocity components with corresponding signal functions that update the velocity (from user input in the players case) and another that updates position from the velocity. My game state is a list of entities and I compose signal functions that do various things. Right not my ECS is just a big record but there are some libraries that I'm considering using once I have a better grasp of SDL: apecs and ecstasy.

turion commented 2 years ago

Ah yes :) that's the kind of thing that we started to develop dunai & rhine for. Have you looked into gloss and rhine-gloss? In case you want some simple SDL 2D vector graphics without worrying too much about the backend.

SheetKey commented 2 years ago

I haven't really looked into gloss. I decided on sdl2 because of the various graphics libraries for haskell it seemed like the most well documented for game programming. Even though its mostly C++ it translates to haskell with very little changes. That being said I haven't done any vector graphics, just loading pngs. If I run into issues I might switch but I haven't had any problems using sdl so far.