FunGEn 项目使用教程

随笔14小时前发布 风间小云
2 0 0

FunGEn 项目使用教程

fungenReplace boilerplate code with functional patterns using ‘go generate’项目地址:https://gitcode.com/gh_mirrors/fu/fungen

1. 项目的目录结构及介绍

FunGEn 项目的目录结构如下:




fungen/


├── examples/


│   ├── hello/


│   ├── pong/


│   └── worms/


├── src/


│   ├── Graphics/


│   │   └── UI/


│   │       └── Fungen/


│   └── GLUT/


├── CHANGELOG.md


├── LICENSE


├── README.md


└── Setup.hs

目录介绍

examples/: 包含示例游戏项目,如 hello, pong, 和 wormssrc/: 包含项目的主要源代码,分为 Graphics/UI/FungenGLUT 两个主要部分。CHANGELOG.md: 记录项目的变更历史。LICENSE: 项目的许可证文件,采用 BSD-3-Clause 许可证。README.md: 项目的主文档,包含项目的基本介绍和使用说明。Setup.hs: 项目的设置文件,用于构建和安装项目。

2. 项目的启动文件介绍

项目的启动文件主要位于 examples/ 目录下,每个示例游戏都有一个主要的启动文件。

示例游戏启动文件

examples/hello/hello.hs: 这是 hello 示例游戏的启动文件。examples/pong/pong.hs: 这是 pong 示例游戏的启动文件。examples/worms/worms.hs: 这是 worms 示例游戏的启动文件。

启动文件内容

examples/hello/hello.hs 为例,启动文件主要包含以下内容:




module Main where


 


import Graphics.UI.Fungen


 


main :: IO ()


main = funInit "Hello World" (0, 0, 0, 0) (640, 480) [] []

module Main where: 定义主模块。import Graphics.UI.Fungen: 导入 FunGEn 库。main :: IO (): 定义主函数。funInit: 初始化游戏窗口和环境。

3. 项目的配置文件介绍

项目的配置文件主要涉及构建和安装的配置。

配置文件

Setup.hs: 项目的设置文件,用于构建和安装项目。fungen.cabal: 项目的 Cabal 配置文件,包含项目的依赖、构建选项等信息。

Cabal 配置文件内容

fungen.cabal 为例,配置文件主要包含以下内容:




name:                FunGEn


version:             1.2


license:             BSD3


license-file:        LICENSE


author:              Andre Furtado


maintainer:          Simon Michael <simon@joyful.com>


build-type:          Simple


cabal-version:       >=1.10


 


library


  exposed-modules:   Graphics.UI.Fungen


                     Graphics.UI.Fungen.Display


                     Graphics.UI.Fungen.Game


                     Graphics.UI.Fungen.Init


                     Graphics.UI.Fungen.Input


                     Graphics.UI.Fungen.Loader


                     Graphics.UI.Fungen.Map


                     Graphics.UI.Fungen.Objects


                     Graphics.UI.Fungen.Text


                     Graphics.UI.Fungen.Timer


                     Graphics.UI.Fungen.Types


                     Graphics.UI.Fungen.Util


                     Graphics.UI.GLUT.Input


  build-depends:     base >=4.9 && <5


                     , base-compat


                     , GLUT


                     , OpenGL


                     , random


  hs-source-dirs:    src


  default-language:  Haskell2010


 


executable fungen-hello


  main-is:           examples/hello/hello.hs


  build-depends:     base


                     , FunGEn


  hs-source-dirs:    examples/hello


  default-language:  Haskell2010


 


executable fungen-pong


  main-is:           examples/pong/pong.hs


  build-depends:     base


                     , FunGEn


  hs-source-dirs:    examples/pong


  default-language:  Haskell2010


 


executable fungen-worms


  main-is:           examples/worms/worms.

fungenReplace boilerplate code with functional patterns using ‘go generate’项目地址:https://gitcode.com/gh_mirrors/fu/fungen

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...