展示 HN:拥有自己 IDE 和脚本语言的游戏引擎

1 分•作者: am-gm•大约 2 个月前
GitHub 仓库:<a href="https://github.com/ArcadeMakerSources/ArcadeMaker" rel="nofollow">https://github.com/ArcadeMakerSources/ArcadeMaker</a> (首先,我想说我做这个项目是为了好玩和挑战。我一直想创造自己的语言。这个项目没有任何商业目标之类的。) 所以,这个项目是一个 2D 游戏引擎(MonoGame 后端),灵感来自 GameMaker 8。它包含自己的 IDE(使用 WinForms 构建)以及一门我自行编写的解释型编程语言。 这门语言——无疑是项目中最大的挑战——是一种简单的动态类型语言。刚开始的时候,我对此类项目的构建一无所知。我甚至不知道我是在做一个解释器;起初我称之为编译器。这是一个个人挑战,我想在不使用任何资源或教程的情况下弄清楚一切。我的想法基本上是:“我需要编写一个软件,它能读取一个包含代码的文本文件,然后执行其中的指令。” 不知何故,我做到了。起初,运行一个计算到 100 万的空循环需要 7 秒。经过大量的性能优化和系统重构后,同一台机器现在可以在 2-3 秒内运行一个 3000 万的循环。这是一个相当不错的进步。 这门语言本身有点不寻常,我想分享一个我非常喜欢的小功能:循环计数器。 ``` foreach item in ['a', 'b', 'c'] : counter c { println(c + ": " + item) } // 输出: // 0: a // 1: b // 2: c ``` 这不是一个复杂的功能,但非常有用。 这是一个 YouTube 视频,展示了我如何使用该引擎构建一个小游戏。 如今,我几乎没有时间来开发这个项目了,所以我决定将其开源。我希望大家能觉得它有趣,并帮助它成为一个真正有用的东西。我正在寻找贡献者! 我知道现在有很多 AI 生成的项目在分享,所以请,请,在假设这是其中之一之前,快速浏览一下代码。我保证很容易看出这是由人类编写的。 欢迎任何反馈。
查看原文
GitHub repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;ArcadeMakerSources&#x2F;ArcadeMaker" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ArcadeMakerSources&#x2F;ArcadeMaker</a> (first of all, i want to say that I made this project for fun and challenge. I always wanted to create my own language. This has no business goal or something.) So the project is a 2D game engine (MonoGame backend) inspired by GameMaker 8. It includes its own IDE (built with WinForms) and an interpreted programming language that I wrote myself. The language—definitely the biggest challenge in the project—is a simple dynamically typed language. When I started, I had zero knowledge of how to build something like this. I didn’t even know I was making an interpreter; at first I called it a compiler. It was a personal challenge, and I wanted to figure everything out without using any resources or tutorials. My mindset was basically: “I need to write software that takes a text file containing code and just does what it says.” Somehow, I made it work. In the beginning, running an empty loop counting to 1M took 7 seconds. After a lot of performance work and rebuilding parts of the system, the same machine can now run a 30M loop in 2–3 seconds. Pretty nice improvement. The language itself is a bit unusual, and I want to share one small feature I really like: loop counters. foreach item in [&#x27;a&#x27;, &#x27;b&#x27;, &#x27;c&#x27;] : counter c { println(c + &quot;: &quot; + item) } &#x2F;&#x2F; Output: &#x2F;&#x2F; 0: a &#x2F;&#x2F; 1: b &#x2F;&#x2F; 2: c Not a complicated feature, but pretty useful. Here&#x27;s a YouTube video showing me using the engine to build a little game Anyway, these days I barely have time to work on the project, so I decided to open-source it. I’m hoping people here will find it interesting and help turn it into something real. I&#x27;m looking for contributors! I know there are tons of AI-generated projects being shared these days, so please, please, take a quick look at the code before assuming this is one of them. I promise it&#x27;s pretty obvious that it was written by a human. Any feedback is welcome.