HackerTrans
TopNewTrendsCommentsPastAskShowJobs

mvx64

no profile record

Submissions

Show HN: A PSX/DOS style 3D game written in Rust with a custom software renderer

totenarctanz.itch.io
57 points·by mvx64·vor 10 Monaten·36 comments

comments

mvx64
·vor 2 Monaten·discuss
Works amazingly well: https://bsky.app/profile/mentalvertex.bsky.social/post/3lzvb...
mvx64
·vor 8 Monaten·discuss
I know I am in the minority and my uses/needs/requirements are not average, but I am perfectly fine with running Xubuntu on the following hardware: 1) 4GB 2011 Thinkpad with HDD (yeah really) and 2) 4GB 2009 Phenom desktop (was Win10 until a month ago).

By fine I mean running all these at the same time: firefox with several tabs, development tools, Blender and GIMP. All snappy and fast. Even the HDD in the laptop is only an annoyance during/after a cold boot. Then it makes no difference. I daily drive both for the past 8-15 years. The laptop sits at ~10-15W idle and the i5 in it is a workhorse if needed.

Of course there are uses for better hardware, I am not dismissing upgrades. But the whole modern hw/sw situation is a giant shipwreck and a huge waste of resources/energy. I've tried very expensive new laptops for work (look up "embodied energy"), and Windows 11 right-click takes half a second to respond and Unity3D can take several minutes to boot up. It's really sad.

edit: To be honest I have to add a counter-example: streaming >=1080p60 video from YT is kind of a no-no, but that's related to the first sentence of my post.
mvx64
·vor 8 Monaten·discuss
I found out about profiles recently and I just couldn't believe that that's the standard way to access them. Also, it's not obvious which profile you are currently on, so there are some silly but necessary workarounds like having a dummy bookmark with the profile name on each or something like that, while it could just be a string next to the address bar.

It works really well though. Does exactly what I would expect and hope from such a feature.
mvx64
·vor 9 Monaten·discuss
Shout out to King's Crook [1], a cool project using a custom C software renderer only using integers

[1] https://kingscrook.itch.io/kings-crook
mvx64
·vor 9 Monaten·discuss
If you keep resolution low, manage your scene complexity carefully and commit to the art style, you can make reasonable 3D games that run even on 20 year old hardware. I did so as an experiment on my game [1] [2] and now that I can see that it works, I am working on a second, more "serious" and complete one. Computers are fast.

[1] https://news.ycombinator.com/item?id=45270981

[2] https://totenarctanz.itch.io/a-scavenging-trip

Really cool news about raylib. I will seriously consider using this.
mvx64
·vor 10 Monaten·discuss
It would be cool indeed, I played around with !include_str and co. and works as expected. It wouldn't be possible for the user to modify the assets though, and to save the settings file.
mvx64
·vor 10 Monaten·discuss
Understandable. That's kind of the goal, the gameplay is very shallow complexity-wise, so raw responses/difficulty is one way to put some playing time into it.

There are some methods that help a lot, like keeping a completely perpendicular or parallel viewing direction, and adjusting the distance with the corresponding set of thrusters. Even slight angles mean you have to randomly mash forward/backward/left/right and hope to keep a steady orbit, it's not gonna happen.

For what it's worth, even for me now, it would take more than 10 tries probably to beat Master on Mission 1.
mvx64
·vor 10 Monaten·discuss
Nice discussions! I've seen many of these projects lately around related communities. Happy to see a trend around this, as I really think there is actual merit in the topic. My project was more of a random timesink than something that pushes the matter forward though.

Do you mean directly e-mail/contact said person?
mvx64
·vor 10 Monaten·discuss
Interesting, I will look more into this.

To be honest, grepping the source, I found a couple of places with for x in &myvec. Probably tried them while learning the language, they worked and left them there.

But really, I am just more used to the old way. It visually feels more familiar, I have an explicit i to do things, and it's easier to delete/manipulate elements while in the loop and not invalidate anything. It's not that I am against an iterator if it matters and it's better, of course.

In my case, the important loops are like "for i in x0..x1 { draw(i, y); }". Is there a way to turn this into something that, for example, skips the bound checks or optimizes it in any other way?
mvx64
·vor 10 Monaten·discuss
Thanks for trying it out. It's a regular inverse square law, no tricks. The numbers (masses, distance) determine the final acceleration but not the actual trend of the curve.

I've become too familiar with it over testing to notice unintuitive behaviour, but I think I understand what feels off: in real world units, the gradual region you describe is very wide, and feels linear. This would make for very boring gameplay (imagine spending minutes to reach the planet). You need to keep the playable area [radiusForce0, radiusForceMax] small. So you will either map that small [r0, rmax] into real world [F0, Fmax], which means the force will be almost constant across, or "compress" the [F0, Fmax] curve so that you can fit both [zero outer space gravity, strong surface gravity] into that [r0, rmax].

That's what happens here, I probably tweaked the values for the second case. It's kind of an accelerated version of reality and the margins feel very tight, and you have to "buy into" that reality.

For example, Master difficulty in Mission 1 may seem impossible, but if you try to be gentle and find a balanced orbit, you can complete it with miniscule fluctuations in distance and minimal input.

Just rambling though, I never really actually designed or balanced the game.
mvx64
·vor 10 Monaten·discuss
Actually yes! I use it when passing a texture into a draw function. I have a TexOrColor enum, and when calling the function you either provide an &Image or a &Color. Before that, if I wanted a colored textureless model, I passed a dummy 1x1 texture to sample from.

And of course, Options and pattern matching are easily the best part of the language and very powerful. I am obsessed with things like "let x = if {...}".
mvx64
·vor 10 Monaten·discuss
You mean implicitly? I am aware that idiomatic Rust strongly prefers iterators over indices for performance, but in my case, the only place where it really matters is when counting pixels to draw, and there is no kind of collection there, just x,y numbers.
mvx64
·vor 10 Monaten·discuss
I'll see if I can produce a reasonably readable stripped down version (the lib + an example scene) and I might be back soon ;)
mvx64
·vor 10 Monaten·discuss
Right, it's a spectrum, you can't avoid some things (and rightly so).

Another soft rule: no member functions (except for the Scenes); structs are only data, all functions are free functions.

Also no operator overloading, so yes, lots of Vec3::add(&v1, &v2). I was hesitant at first but this makes for more transparent ops (* is dot or cross?) and does not hide the complexity.

The whole thing is around 6-7kloc and I think it would be possible to rewrite in C++ in a day or two.
mvx64
·vor 10 Monaten·discuss
It's all single threaded. Just structs being passed around. For example, the mesh drawing call is:

drawmeshindexed(m: &Mesh, mat: &Mat4x4, tex: &Image, uv_off: &TexCoord, li: &LightingInfo, cam: &Camera, buf: &mut Framebuffer)

so there is also no global state/objects. All state is passed down into the functions.

There were some cases that RefCells came in handy (like having an array of references of all models in the scene) and lifetimes were suggested by the compiler at some other similar functions, by I ended up not using that specific code. To be clear, I have nothing against those (on the contrary), it just happened that I didn't need them.

One small exception: I have a Vec of Boxes for the scenes, as SceneCommon is an interface and you can't just have an array of it, obviously.
mvx64
·vor 10 Monaten·discuss
It's a very procedural style. I have not used: iterators, lifetimes, Arcs/Boxes/RefCells and whatnot, any kind of generics, data structures other than vecs/arrays, async, and many more. Also avoided functional style, builder patterns...

I only used traits to more easily implement the scenes; a Scene needs to implement a new(), a start() and an update(), so that I can put them in an array and call them like scenes[current_scene_idx].update() from the main loop.

Also, I used some short and simple closures to avoid repeating the same code in many places (like a scope-local write() closure for the menus that wraps drawtext() with some default parameters).

The vast majority of the time is spent in the triangle filling code, where probably some autovectorization is going on when mixing colors. I tried some SIMD there on x86 and didn't see visible improvements.

Apart from obvious and low-hanging fruit (keeping structs simple, keeping the cache happy, don't pass data around needlessly) I didn't do anything interesting. And TBH profiling it shows a lot of cache misses, but I didn't bother further.
mvx64
·vor 10 Monaten·discuss
Yeah it should be just a simple cargo build. But for the same reason it should be playable through any emulator/translation/VM layer as you mentioned.
mvx64
·vor 10 Monaten·discuss
Didn't know this, but I'd rather not use github to be honest. Isn't there also some kind of signing required to publish a Mac build?
mvx64
·vor 10 Monaten·discuss
The game-side code, not really (I am ashamed of reading it myself). The engine-side is a bit less shameful, but I'd rather not as I mentioned elsewhere, especially on github. I may change my mind though.
mvx64
·vor 10 Monaten·discuss
I have considered getting a Mac in the past (even a very old Air) to make and, most importantly test, Mac builds, but I never got to it and cross-compiling to Mac seems like a pain, if at all possible. If you have a VM laying around though, it should work.

A good thing about the approach is that if it compiles, it should work exactly the same everywhere and with predictable/linear performance, no matter the environment or driver situation.