TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Writing a 3D Game in C (in 2022)

27 点作者 aarongeisler超过 2 年前

9 条评论

sylware超过 2 年前
Very nice.<p>That said even C has already a way too rich and complex syntax. ISO is doing planned obsolescence with its syntax instead of fixing it, and no the linux kernel is not written in C, but using a gcc-massively-extended C dialect.<p>Then it needs discipline: c89 with benign bits of c99&#x2F;c11&#x2F;etc.<p>A good move is to write&#x2F;use a C coded game engine, I wish godot was plain and simple C.
评论 #33902606 未加载
pengaru超过 2 年前
<p><pre><code> &gt; deep cloning of data with simple assignment a = b; &gt; deep equality checks bool are_equal_by_value = memcmp(a, b, sizeof(some_struct_t)); </code></pre> Errr, wat? We seem to have very different understandings of &quot;deep&quot; in this context. Neither of the above are &quot;deep&quot; in the sense that pointers within the struct will not be followed with their referenced data copied&#x2F;compared. These are <i>shallow</i> operations.
评论 #33887030 未加载
Rochus超过 2 年前
Interesting read, thanks.<p>&gt; <i>C++ is the obvious choice but the syntax and endless features overwhelm me. I’m not a fan of OOP for game development - class-heavy C++ was not the right move</i><p>You can well use C++ with a very modest style, even completely without OO if needed; C++ has many advantages over C for large projects; the type system is more mature and it offers very useful features for modularization and memory management (which were already present in C++98, so it&#x27;s easy to get a working compiler on virtually all platforms where there is a C compiler).
评论 #33887848 未加载
krapp超过 2 年前
Where&#x27;s the source code for the game itself? The github page you linked to lists resources, and a Steam page for the game, but not the code itself. That would be the most interesting thing for HN, otherwise this just seems like a submarine ad for your game.<p>If you&#x27;re going to use FOSS code for your project you should release it as such.<p>That said, congrats on releasing. I play around with C a lot but couldn&#x27;t imagine sticking with it long enough to finish something bigger than a library.
kurtreed超过 2 年前
<p><pre><code> bool are_equal = memcmp(&amp;a, &amp;b, sizeof(some_struct_t)); </code></pre> Isn&#x27;t this a bug? Structs are allowed to have padding bytes between bytes occupied by fields, which will have unpredictable (&quot;garbage&quot;) values. So a pair of structs with all fields pairwise same can have different padding bytes, so checking equality with this method will give a false negative.
rpigab超过 2 年前
Nice, thanks for sharing!<p>If you don&#x27;t like C++ because of classes and clutter, would Rust be a viable alternative (asking because I have not much experience in C and in Rust, so maybe if I ever try to write a very simple game engine, I might like to try in Rust)?
mickmack_超过 2 年前
I don&#x27;t understand why you would use C over C++ for anything other than random embedded devices where you have very intimate knowledge of the hardware. I guess you just really hate any hint of a type system?
评论 #33887964 未加载
kahlonel超过 2 年前
All the best! There are many _huge_ projects written in pure C. Don’t let people tell you C is bad for your project size.
aarongeisler超过 2 年前
Reflections on building and publishing a game using a 50 year old language.