在程序开始时,用户可以给模拟一些“信息”:
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 函数。
提前致谢。