展示HN:拥有自己IDE和脚本语言的游戏引擎
GitHub 仓库:<a href="https://github.com/ArcadeMakerSources/ArcadeMaker" rel="nofollow">https://github.com/ArcadeMakerSources/ArcadeMaker</a>
(首先,我想说我做这个项目是出于乐趣和挑战。我一直想创建自己的编程语言,这个项目没有商业目标或其他目的。)
这个项目是一个受 GameMaker 8 启发的 2D 游戏引擎(基于 MonoGame)。它包含了自己的 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://github.com/ArcadeMakerSources/ArcadeMaker" rel="nofollow">https://github.com/ArcadeMakerSources/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 ['a', 'b', 'c'] : counter c
{
println(c + ": " + item)
}
// Output:
// 0: a
// 1: b
// 2: c
Not a complicated feature, but pretty useful.
Here'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'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's pretty obvious that it was written by a human.
Any feedback is welcome.