completed

1 parent 9551e0b commit 0719c6abd1459d0b0e28dd47385510f5df1d863b committed Apr 16, 2012
Showing with 84 additions and 8 deletions.
1. .index.html.swp
2. images/big_pic.jpg
3. +84 −8 index.html
Binary file not shown.
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
 @@ -155,20 +155,96 @@

I got it, give me one more chance, I can still do it, boss!

-

Functional Reactive programming to the rescue

-

- A signal is a type value related to continuous time: -

Signal a = Time -> a
- A signal function is a function from Signal to Signal: -
SF a b = Signal a -> Signal b
-

+

Functional Reactive programming to the rescue!

+
- Signal function combinators composite function(s) to a Signal Function: + Definiation of FRP - functions react to an input signal and returns an updated signal.

+ A signal is a type value related to continuous time: +
Signal a = Time -> a
+ A signal function is a function from Signal to Signal: +
SF a b = Signal a -> Signal b
+ You can't touch the signals without using sigal functions. +
+ +
+ Signal function combinators composite function(s) to a Signal Function: + You can't touch the signal functions without using combinators. +
+ +
+

Nice! we can now do:

+
+signal(position, speed, mouseXY)
+    -> PlayerFunction
+        -> signal(position, speed, mouseXY)
+
+
+

+

An event is a type to represent discrete events such as a mouse click: +

data Event a = NoEvent | Event a
+

+
+
+ +
+

Looks like we are almost there:

+
+  -> PlayerFunction
+    -> signal(position, speed, mouseXY, gamepadEvent, collisionEvent)
+
+
+

But but but, what if my player dies? How do I remove and spawn?

+

Also, how does my object know if it is colliding with each other?

+
+ +
+

The last piece of the puzzle: Switches!

+ Switch switches from one subordinate signal function into another when a switching event occurs. +
+            switch :: SF a (b, Event c) ->
+              (c -> SF a b) -> SF a b
+
+
+

What is this non-sense? What are these strange symbols stand for?

+

It's haskell...I know. It says a switch will take an activated signal function with a trigger event, and another signal function as input. If the trigger event occurs, it applies the second signal function, else it applies the original signal function. +

+
+
+

The big picture

+ We use switches to route events and switch on/off game objects for spawn/kill. + +
+ + +
+

Conclusion

+
+
+

Q:What framework can I start to use FRP for game dev? +
+ A:My presentation is based on the Yampa framework in Haskell

+

Q:How well is this method perform? +
+ A:Paul Hudak made a game "PaddleBall" with 17 lines of code in FAL

+

Q:Is there example of complex game out there made with FRP? +
+ A:Check out Frag, a first personal shooter game

+
+
+ +
+

Reference

+
+
• Henrik Nilsson, Antony Courtney, John Peterson, "The Yampa Arcade", 2003
• +
• Mun Hon Cheong, "Functional Programming and 3D games", 2005
• +
+