ABSTRACT
Video games are usually not programmed very declaratively. There are a number of reasons for this, from low-level efficiency concerns, via the nature of commonly employed programming languages, libraries, and frameworks, to the conceptual nature of such games, with state and effects being omnipresent. However, by structuring games in terms of time-varying values and transformations on such values, it is possible to design and implement video games in a more declarative way. This tutorial shows how this can be achieved through Functional Reactive Programming (FRP) by implementing the high-level parts of a 2D game akin to the classical game Breakout. The tutorial uses the Haskell-embedded FRP implementation Yampa and bindings to SDL (Simple DirectMedia Layer) to obtain game play and visual standards typical of the 2D genre; for example, as seen in many currently popular games for smartphones and tablets.
- P. Caspi, D. Pilaud, N. Halbwachs, and J. A. Plaice. LUSTRE: A declarative language for programming synchronous systems. In Proceedings of the 14th ACM Symposium on Principles of Programming Languages, New York, NY, 1987. ACM. Google ScholarDigital Library
- M. H. Cheong. Functional programming and 3D games. BEng thesis, University of New South Wales, Sydney, Australia, Nov. 2005.Google Scholar
- A. Courtney, H. Nilsson, and J. Peterson. The Yampa arcade. In Proceedings of the 2003 ACM SIGPLAN Haskell Workshop (Haskell'03), pages 7--18, Uppsala, Sweden, Aug. 2003. ACM Press. Google ScholarDigital Library
- C. Elliott and P. Hudak. Functional reactive animation. In Proceedings of ICFP'97: International Conference on Functional Programming, pages 163--173, June 1997. Google ScholarDigital Library
- J. Hughes. Generalising monads to arrows. Science of Computer Programming, 37:67--111, May 2000. Google ScholarDigital Library
- H. Nilsson, A. Courtney, and J. Peterson. Functional reactive programming, continued. In Proceedings of the 2002 ACM SIGPLAN Haskell Workshop (Haskell'02), pages 51--64, Pittsburgh, Pennsylvania, USA, Oct. 2002. ACM Press. Google ScholarDigital Library
- R. Paterson. A new notation for arrows. In Proceedings of the 2001 ACM SIGPLAN International Conference on Functional Programming, pages 229--240, Firenze, Italy, Sept. 2001. Google ScholarDigital Library
Index Terms
- Declarative Game Programming: Distilled Tutorial
Recommendations
Functional reactive programming, refactored
Haskell 2016: Proceedings of the 9th International Symposium on HaskellFunctional Reactive Programming (FRP) has come to mean many things. Yet, scratch the surface of the multitude of realisations, and there is great commonality between them. This paper investigates this commonality, turning it into a mathematically ...
Fault tolerant functional reactive programming (functional pearl)
Highly critical application domains, like medicine and aerospace, require the use of strict design, implementation and validation techniques. Functional languages have been used in these domains to develop synchronous dataflow programming languages for ...
Monadic functional reactive programming
Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on HaskellFunctional Reactive Programming (FRP) is a way to program reactive systems in functional style, eliminating many of the problems that arise from imperative techniques. In this paper, we present an alternative FRP formulation that is based on the notion ...
Comments