17 ms·
A simple Minecraft written in Rust
- gnocchi 12y agoLots of other examples here too https://github.com/PistonDevelopers https://github.com/PistonDevelopers and website available here http://www.piston.rs/ http://www.piston.rs/ for those who want to get started with piston
- kvark 12y agoNote that Hematite uses gfx-rs for rendering, it was mentioned on HN earlier: https://news.ycombinator.com/item?id=8610459 https://news.ycombinator.com/item?id=8610459
- abtinf 12y agoFirst person to say something like "This isn't minecraft, minecraft is way more than just placing blocks!" loses.
- kibwen 12y agoLast I heard, Hematite was more of a Rust-based renderer of Minecraft worlds than an actual game. For example, I don't think it currently supports construction or destruction of blocks. Piston, the project that's backing Hematite, is very interesting in that it's an attempt to explore idiomatic approaches to game engine design in Rust. I'm not sure how many game developers will value Rust's memory safety over C++'s sheer flexibility and mature tooling, but I commend the Piston developers for taking a chance on a new and unproven language! EDIT: If you'd like to take a closer look at game development in Rust, be aware that there exist dedicated communities for this on reddit ( http://www.reddit.com/r/rust_gamedev http://www.reddit.com/r/rust_gamedev ) and IRC ( http://client01.chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev http://client01.chat.mibbit.com/?server=irc.mozilla.org&chan... , a.k.a. #rust-gamdev on irc.mozilla.org).
- steveklabnik 12y agoAlso, last time I heard, they were shooting for pixel-perfect rendering, which is really interesting.
- astrodust 12y agoWhat does that mean in this case?
- kibwen 12y agoI believe it means that the developers made an effort to exactly mimic Minecraft's lighting and ambient visual effects, rather than simply slapping the textures on the geometry and calling it a day.
- steveklabnik 12y agohttp://imgur.com/a/bHcLD http://imgur.com/a/bHcLD They're trying to make those two images look exactly the same.
- lloeki 12y ago> I'm not sure how many game developers will value Rust's memory safety over C++'s sheer flexibility and mature* tooling* Spot on. What sets an immediate roadblock for me is this, straight from the Piston readme: > You should be able to run the command rustc -v > You should be able to run the command cargo -V The first one is incredibly easy: brew install rust, which currently brings in 1.0.0-alpha. The second one, well†... Its very homepage[0] says: > The easiest way to get Cargo is to get the Rust nightly build So the only easy step out of two is instantly invalidated. This is followed by: > This will get you the latest Rust nightly for your platform along with the latest Cargo. You should run this script almost every day to get the latest updates. Okay so the de facto standard dependency manager is apparently deeply tied to rust itself, yet not included in the rust distro, and it's apparently quite not stable enough to warrant daily updates. And even 1.0.0 (granted, "-alpha") doesn't include it, so it may not be ready before god knows when. Compare: export GOPATH=$(pwd) brew install glew brew install homebrew/versions/glfw3 go get github.com/go-gl/gl go get github.com/go-gl/glfw3 vim whatever.go # https://github.com/go-gl/glfw3#example go run whatever.go # yay OpenGL! This means that although Piston does look great, and Rust looks promising, it does not look not dependable right now, because it just doesn't feel mature (even if it is, which I don't know, because my time is limited and there were enough explicit or implicit warnings about dragons to turn me away). † I'm perfectly aware that cargo is available as a Cask, but for various reasons, I don't want casks in my system, and it doesn't preclude the remainder of the discussion. [0]: http://doc.crates.io http://doc.crates.io
- serge2k 12y agoDo you know what alpha means? or were you just wanting to talk about go?
- lloeki 12y ago> Do you know what alpha means? Precisely†. This is just to give some credence to the "mature" part of the parent comment, beyond language features and alleged "proven-ness". I'm not complaining in any way, just reporting how things are or can be perceived. The comparison with Go is purely factual: I just happen to have done exactly this in Go, and recollected an account of my experience when I wanted to explore doing the same thing in Rust. If referencing Go has to do with anything, it's laziness as I extracted that from my shell history. I am deeply sorry if the above post sounded snarky or whatever. This was not the intent. † BTW, when I did this originally, Rust was 0.9 (no alpha anywhere), which has the virtue of saying squat about what you should expect without a statement of version semantics (e.g node.js is 0.12 and definitely production-ready)
- toqueteos 12y agoBuild appears as broken but it should be working, Travis is doing its thing. EDIT: Green Travis again :)
- mdaniel 12y agoI don't feel like submitting a PR for it, but you have one syntax error and one suboptimal piece of syntax in the readme at the bottom: The Windows section should read: Minecraft folder: %appdata%\minecraft Worlds folder: %appdata%\minecraft\saves\<world> (observe the "closing" percent sign) and the OSX one could read: Minecraft folder: $HOME/Library/Application Support/minecraft Worlds folder: $HOME/Library/Application Support/minecraft/saves/<world> or, of course, using the same tilde syntax as in Linux.
- toqueteos 12y agoFixed! Thanks
- idunning 12y agoHow is that dependency graph plotted in the README?
- calrogman 12y agoUsing Dot, I think. https://github.com/maxsnew/cargo-dot https://github.com/maxsnew/cargo-dot
- maxiepoo 12y agoYep, I wrote that as my first project in rust and it was used for a lot of the Piston project repos. Unfortunately I stopped updating that in December because breaking changes were happening too frequently for me to keep up. I'll probably revisit it soon now that 1.0 is fairly imminent, but prs are welcome of course!
- escherize 12y agoI'm not associated with the project, but it looks like graphviz (http://graphviz.org/ http://graphviz.org/) to me. graphiz is amazing for making graphs. My favorite interface for it is dorothy (https://github.com/daveray/dorothy https://github.com/daveray/dorothy).
- qznc 12y agoGraphviz is ok for quickly plotting a dependency graph. I have yet to see a beautiful example of auto-layouted graphs. Beautiful means getting the details right like lines not crossing at narrow angles, drawing a little "hop" when lines cross, and not being restricted to strict rows like dot.
- idunning 12y agoHow is that dependency graph plotted in the README?
- mjfl 12y agoSomething I always wonder for games not made with C++: how is the performance?
- VMG 12y agoThough in this case it makes sense to compare it to the "reference implementation" in Java. Regular Minecraft has noticeable GC pauses in my opinion.
- kibwen 12y agoHematite doesn't implement anything near to the full game, so it wouldn't be a fair comparison. It's mostly just a world visualizer, sort of like Overseer is for Dwarf Fortress ( http://www.bay12forums.com/smf/index.php?topic=63484 http://www.bay12forums.com/smf/index.php?topic=63484 ). And although it would probably make a good jumping-off point for anyone who wanted to develop a Minecraft clone, the original goal of Hematite was only to serve as a proof-of-concept of rendering 3D graphics in Rust.
- pkolaczk 12y agoAre you sure they are caused by GC? I'm asking because GC is an easy "culprit" and when a Java app pauses / jitters, many people immediately blame it on GC without any hard evidence. While in fact pauses / unresponsiveness can be caused by many other reasons, not specific to JVM (e.g. improper thread locking, improper use of dynamic data structures, doing hard work on the GUI thread, etc.). Actually, a well coded game should not use dynamic memory allocation in the game loop, neither in Java nor in C++.
- Havvy 12y agoI've seen Minecraft generate 400Mb/min worth of garbage and then GC with a noticable stutter. The most egregious stutter though is when Minecraft generates new chunks. Minecraft is not a well-coded game. ;)
- Manishearth 12y agoNote: Rust is designed to be as efficient as C++. Well, sort of, since we don't have all of the optimizations yet (we use llvm so we get most of them for free) But Minecraft itself is in Java. And it does get pretty slow even with low settings as compared to other games on high settings.
- donpdonp 12y agoIf you're looking to play a open source minecraft-like game, without worrying about microsoft copyrights on world files, http://minetest.net/ http://minetest.net/ is a lot of fun.
- 0942v8653 12y ago> microsoft copyrights on world files If that were something to worry about, then wouldn't OpenOffice, LibreOffice, iWork, Google Docs, etc. all be in legal trouble right now for the same thing with .doc files?
- orclev 12y agoNope because MS doesn't create .doc files, they just make the software that saves/loads them. The issue in this case is that the Minecraft textures and item geometry are created by MS (by way of Mojang) and hence MS has the copyright on them. If you replace the textures with alternative ones created by other people you're probably in the clear so far as the textures go, but the NPCs and objects geometry data is still covered.
- indenturedsmile 12y agoBut the world files are just the save files. As far as I know, there are no texture or object data in the saves.
- sitharus 12y agoDefinitely true. Plus there's a long standing precedent that save files aren't copyrightable, since they aren't a derivative work.
- wlesieutre 12y agoOne could maybe make the case that Minecraft's terrain generation would make your world a derivative work, but if you're building in superflat than definitely agreed. I have no idea about the former, but if MS had any claim to a world built from scratch then Adobe would own everything ever made in Photoshop and Autodesk would own pretty much all video game content since the late 90s.
- ConfuciusSay 12y agoNice job, now if you can make a simple Rust in Minecraft I'll be even more impressed!
- yellowapple 12y agoRust program compiled for a redstone computer running on Hematite, which in turn has been compiled for a redstone computer running on Hematite. Recursion at its finest.
- Navarr 12y agoNext up: A simple Rust written in Rust.
- Devagamster 12y agoIsnt that just rust? Rust is written in rust...
- evincarofautumn 12y agoBut I wouldn’t call it simple. rustc is a couple hundred thousand lines of code, split across several libraries. librustc_borrowck alone is almost six thousand lines.
- geofft 12y agoI assume the joke is that "Rust" is the name of a video game inspired by Minecraft (and other games): http://playrust.com/ http://playrust.com/
- Navarr 12y agoYou assume right!
- anonbanker 12y agoI hope Microsoft plays nice with these clones in the future. Especially when they use official assets.
- GoofballJones 12y agoNow write the game "Rust" in Minecraft.
- harry8 12y agoI have a question for people who've advanced ahead of me into rust. With the C and the kind of C++ I write I have some kind of idea what the assembly language that will be generated by the code I'm writing looks like. I have some idea how the data is going to be laid out in memory. You can think of C and good C++ code as a more convenient way of writing the machine instructions that will execute on your cpu, well at least kinda. But you really can't do this with say, haskell or clojure (he said aware he knows little about the former and even less about the latter). How is rust? Can you write some rust code knowing this datastructure will be laid out like so, knowing this function will likely not thrash cache too badly and so on? Inline asm? If you had the crazy idea of writing the "platinum" linker in rust in an attempt to outperform the (written in c++) gold linker is that doomed before you start. Nothing to choose for efficiency between these languages? Oh and how's the debugger? Same as gdb on c++?
- kibwen 12y agoBeing able to have an idea of the assembly that will be generated from Rust code is certainly a motivating goal (I believe that pcwalton has previously indicated his ability to divine as much), though I personally have no experience with bare assembly so I cannot attest to it myself. You can certainly guarantee data layout (such is required for C interop, for which Rust has very nice support), though by default Rust will e.g. reorder a struct's fields in order to optimize its representation (taking into account padding and such) unless you explicitly ask it not to. Rust also tries to favor explicitness where it can. For example, even though many people have requested C#-style properties where `foo.bar = baz` can implicitly call a setter function, Rust has rejected this because the runtime behavior of a function call is too different from the runtime behavior of a field lookup. As another example, anything that looks like `foo.bar()` will always be a method call, and `foo.bar` (without direct parentheses) will always be a field lookup, so if you want to call a function pointer stored in a struct field you need to write `(foo.bar)()`. There are also places where Rust is more explicit than C++. For example, a C++ function `void bar(int& foo)` can be called like `bar(6)`, but the analogous Rust function `fn bar(foo: &i32)` must be called like `bar(&6)`. However, Rust also has places where it is less explicit than C++. For example, whereas C++ has both `bar.foo()` for direct method calls and `bar->foo()` for method calls that are invoked through a deref, Rust has only `bar.foo()` which has the capability to dereference `bar` if necessary. So it would be incorrect to say that Rust is ultimately more or less explicit than C++... it just has a different mix of explicit and implicit operations. As to the rest, Rust does indeed have inline asm, and I hear that Rust produces DWARF debuginfo which allows it to be debugged via gdb (though it has to pretend to be C++ in order to play nicely with existing tooling, which can make it awkward sometimes).