0

在程序开始时,用户可以给模拟一些“信息”:

    main:: IO()
        main = do
        putStrLn("Hallo")
        val <- getLine
        startGUI(read val ::Float)

函数(startGUI):

startGUI :: Float -> IO ()
startGUI si  = simulate window background fps initialState render $ moveBall si

启动一个函数,这是模拟的某种循环。它基本上更新了游戏。

moveBall 函数定义如下:

moveBall :: Float -> Float -> PongGame -> PongGame
moveBall seconds go game = game { ballLoc = (x', y') }
...

我得到的错误消息是:

Couldn't match type ‘PongGame’ with ‘PongGame -> PongGame’
    Expected type: ViewPort -> Float -> PongGame -> PongGame
      Actual type: Float -> PongGame -> PongGame
    Possible cause: ‘moveBall’ is applied to too many arguments
    In the second argument of ‘($)’, namely ‘moveBall si’
    In the expression:
      simulate window background fps initialState render $ moveBall si

它指的是 startGUI 函数。

提前致谢。

4

1 回答 1

1

传递启动信息的关键是通过 initalState 函数传递它们。

startGUI :: Float -> IO ()
startGUI si  = simulate window background fps (initialState si) render  update

然后你只需要为游戏配置你的数据集。

于 2016-08-31T19:34:51.990 回答