FunGEn 项目使用教程

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, 和 worms
  • src/: 包含项目的主要源代码,分为 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

  • 15
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

施余牧

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值