This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm writing a pong game, I need some help with the game logic. My problem is that is that I got problems to detect if the ball is out of the map or not, this causes that the ball just gets out-of-bounds and no score is counted. Currently it works like this: | |
stepScore :: State -> State | |
stepScore s | |
| s^.ball.pos.x <= 15 = resetGame $ score.right +~ 1 $ s | |
| s^.ball.pos.x >= 585 = resetGame $ score.left +~ 1 $ s | |
| otherwise = s | |
and resetGame works as such: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Control.Lens | |
import FRP.Elerea.Simple hiding (delay) | |
import FRP.Helm | |
import FRP.Helm.Time | |
import qualified FRP.Helm.Keyboard as Keyboard | |
import qualified FRP.Helm.Window as Window | |
import qualified FRP.Helm.Text as Text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Pong in Haskell using Helm game engine and Lens for mutating the nested data structures. | |
-- For some bloody reason this doesn't work, stay away from Haskell, stay away from abtractions and theory. | |
-- It will ruin your brain. Sad but true, Haskell sucks. | |
-- "If it compiles it's correct"... what a joke... | |
{-# LANGUAGE TemplateHaskell #-} | |
module Pong where | |
import Control.Lens |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
module Pong where | |
import Control.Lens | |
import FRP.Elerea.Simple hiding (delay) | |
import FRP.Helm | |
import FRP.Helm.Time | |
import qualified FRP.Helm.Keyboard as Keyboard | |
import qualified FRP.Helm.Window as Window | |
import qualified FRP.Helm.Text as Text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell #-} | |
module Pong where | |
import Control.Lens | |
import FRP.Elerea.Simple hiding (delay) | |
import FRP.Helm | |
import FRP.Helm.Time | |
import qualified FRP.Helm.Keyboard as Keyboard | |
import qualified FRP.Helm.Window as Window | |
import qualified FRP.Helm.Text as Text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This is an translation of http://elm-lang.org/edit/examples/Intermediate/Mario.elm | |
-- to Haskell using Helm game engine | |
-- This is WIP | |
import Prelude hiding (Either(..)) | |
import FRP.Elerea.Simple | |
import FRP.Helm | |
import FRP.Helm.Time | |
import qualified FRP.Helm.Window as Window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Prelude hiding (Either(..)) | |
import FRP.Helm | |
data Direction = Left | Right | |
data Mario = | |
Mario { mX :: Double, mY :: Double, | |
vX :: Double, vY :: Double, | |
dir :: Direction } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Based on 1st figure: http://doc.cat-v.org/bell_labs/utah2000/) | |
A high-end workstation then, sometime ago and now | |
1990 2000 2013 | |
Hardware | |
33 MHz Mips R 3000 600 MHz Alpha or Pentium III Intel Core i7 3.5 GHz 4 cores or AMD FX-9590 4,7Ghz 8 cores | |
32 megabytes of RAM 512 megabytes of RAM 16 GB RAM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- NOTE: I'm using pipes 4.0 here. | |
module Main where | |
import Pipes | |
import qualified Pipes.Prelude as P | |
import Control.Monad (forever) | |
main = runEffect $ client >>~ server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- NOTE: I'm using pipes 4.0 here. | |
module Main where | |
import Pipes | |
import qualified Pipes.Prelude as P | |
main = runEffect $ server >-> client | |
server :: () -> Server String String IO () |