幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 6651|回复: 4

[通用编程] 编程语言nimrod:果然这个世界上总会有人爱好相同

[复制链接]

136

主题

1751

帖子

548

积分

版主

Rank: 7Rank: 7Rank: 7

积分
548
发表于 2012-11-5 20:10:54 | 显示全部楼层 |阅读模式
http://nimrod-code.org
主要是仿制python,另外还有一些pascal的风格
总之没有了同样是先编译成c的,Genie必需glib库的麻烦,也不像Zimbu关键字大写,结尾单花括号的那么别扭。
主流c编译器nimrod都支持。可以直接用vc,这就砍掉了d语言只认omf格式的短腿。

虽然才0.9版本,库已经几乎比较全面了,像线程,容器,网络,xml&json支持,unicode,加密算法,redis数据库访问,数据库mysql,mongo,sqlite...,正则表达式,zip,ssl,winapi,x11,pcre,tre,cairo,sdl, opengl,gtk,iup,libcurl,libuv,openssl......
可惜,对游戏开发来说,应该还少了个openal。
只是对于nimrod,直接用工具转换下H文件就可以用c库了。所以openal,bass什么的也不是问题。
就连脚本语言,它都支持了3个lua,tcl和python。

已经开发有一个ide。
总的来说非常不错,可玩性相当的高。

在github上看到的一个例子,这代码写出来,那是绝对的漂亮。ps.只 是我个人的感觉:)
  1. import glfw
  2. import opengl ## TODO: Maybe import opengl in glfw ?
  3. import strutils
  4. ## -------------------------------------------------------------------------------
  5. var
  6.     running : bool = true
  7.     frameCount: int = 0
  8.     lastTime: float = 0.0
  9.     lastFPSTime: float = 0.0
  10.     currentTime: float = 0.0
  11.     frameRate: int = 0
  12.     frameDelta: float = 0.0
  13.     x: float = 0.0
  14.     y: float = 0.0
  15.     vx: float = 200.0
  16.     vy: float = 200.0
  17.     windowW: int = 640
  18.     windowH: int = 480
  19. ## -------------------------------------------------------------------------------
  20. proc Initialize() =
  21.    
  22.     if Init() == 0:
  23.         write(stdout, "Could not initialize GLFW! \n")
  24.     if OpenWindow(windowW.cint, windowH.cint, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == 0:
  25.         Terminate()
  26.    
  27.     opengl.loadExtensions()
  28.     SwapInterval(1)
  29.     glClearColor(0.1,0.1,0.1,1.0)
  30.     glClearDepth(1.0)
  31.     glEnable(GL_BLEND)
  32.     glDisable(GL_LIGHTING)
  33.     glCullFace(GL_BACK)
  34.     glDisable(GL_DEPTH_TEST)
  35.     glViewport(0,0,windowW,windowH)
  36.     glMatrixMode(GL_PROJECTION)
  37.     glOrtho(0.0, float(windowW), float(windowH), 0.0, 0.0, 1.0)
  38.     lastTime = GetTime()
  39.     lastFPSTime = lastTime
  40. ## -------------------------------------------------------------------------------
  41. proc Update() =
  42.    
  43.     currentTime = GetTime()
  44.     frameDelta = currentTime - lastTime
  45.     lastTime = currentTime
  46.     if currentTime - lastFPSTime > 1.0:
  47.         frameRate = int(float(frameCount) / (currentTime - lastFPSTime))
  48.         SetWindowTitle("FPS: $1" % intToStr(frameRate))
  49.         
  50.         lastFPSTime = currentTime
  51.         frameCount = 0
  52.     frameCount += 1
  53.     x += vx * frameDelta
  54.     y += vy * frameDelta
  55.     var w = float(windowW)
  56.     var h = float(windowH)
  57.     if x > w - 100.0:
  58.         x = w - 100.0
  59.         vx *= -1.0
  60.     elif x < 0.0:
  61.         x = 0.0
  62.         vx *= -1.0
  63.     if y > h - 100.0:
  64.         y = h - 100.0
  65.         vy *= -1.0
  66.     elif y < 0.0:
  67.         y = 0.0
  68.         vy *= -1.0
  69. ## --------------------------------------------------------------------------------
  70. proc Render() =
  71.    
  72.     glClear(GL_COLOR_BUFFER_BIT)
  73.     glMatrixMode(GL_MODELVIEW)
  74.     glLoadIdentity()
  75.     glBegin(GL_QUADS)
  76.     glColor3f(0.9,0.2,0.49)
  77.     glVertex3f(x, y, 0.0)
  78.     glVertex3f(x + 100.0, y, 0.0)
  79.     glVertex3f(x + 100.0, y + 100.0, 0.0)
  80.     glVertex3f(x, y + 100.0, 0.0)
  81.     glEnd()
  82.     SwapBuffers()
  83. ## --------------------------------------------------------------------------------
  84. proc Run() =
  85.    
  86.     while running:
  87.    
  88.         Update()
  89.         Render()
  90.         running = GetKey(GLFW_KEY_ESC) == GLFW_RELEASE and
  91.                   GetWindowParam(GLFW_OPENED) == GL_TRUE
  92. ## ==============================================================================
  93. Initialize()
  94. Run()
  95. Terminate()
复制代码
え~え~お!!!
回复

使用道具 举报

136

主题

1751

帖子

548

积分

版主

Rank: 7Rank: 7Rank: 7

积分
548
 楼主| 发表于 2012-11-5 20:47:19 | 显示全部楼层
另外还有一些有用的资源:

https://github.com/dom96/jester
模仿了ruby的微型网页开发框架sinatra的网页开发框架

https://github.com/Vladar4/nimgame
一个才0.3还没有完成的游戏框架,基于sdl

https://github.com/fowlmouth/nimrod-glfw
glfw的移植

https://github.com/fowlmouth/nimrod-sfml
sfml 2.0

https://github.com/fowlmouth/nimrod-chipmunk
2d物理引擎chipmunk

https://github.com/fowlmouth/nimlibs
assimp, devil 图像处理
bullet ode 3d物理引擎
clutter 3d加速的2.5d GUI库
ftgl opengl的渲染

https://github.com/fowlmouth/nimrod-enet
udp网络开发包 enet

https://github.com/apriori/nimCL
opencl
え~え~お!!!
回复 支持 反对

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2012-11-5 22:27:19 | 显示全部楼层
这。。。自己写个脚本??游戏开发??
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

24

主题

117

帖子

1274

积分

⑥精研

积分
1274
QQ
发表于 2013-2-4 17:10:36 | 显示全部楼层
我对这种编程语言不感兴趣,符号太复杂了 Orz
还是C/C++或者是C#这样的好。
最好能弄一个可以编写Native的C#
Tamashii是啥意思? 魂! ======================= 我真是败给C++的面向对象了啊……
回复 支持 反对

使用道具 举报

7

主题

190

帖子

1766

积分

⑥精研

....

积分
1766
发表于 2022-4-11 14:57:38 | 显示全部楼层
讲真,回头来看这帖子,这语言看起来确实有很好的底子,可惜没大应用发展起来。
滚滚长江东逝水,浪花淘尽英雄。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-3-29 16:36 , Processed in 0.027168 second(s), 21 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表