在程序开始时,用户可以为模拟提供一些“信息”:
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函数。
提前致谢。
答案 0 :(得分:1)
关键是传递开始信息是通过initalState函数传递它们。
startGUI :: Float -> IO ()
startGUI si = simulate window background fps (initialState si) render update
然后你只需为游戏配置你的数据集。