Live data from Hacker News

Making a Game in Rust

michaelfairley.com

51–60 of 125 posts

Re: Making a Game in Rust

#51
post #2

Great stuff, lines up a lot with what I'd care about as an ex-gamedev and spending a bit of time with Rust. One minor point: > First class code hot-loading support would be a huge boon for game developers. The majority of game code is not particularly amenable to automated testing, and lots of iteration is done by playing the game itself to observe changes. I’ve got something hacked up with dylib reloading, but it re…

Lua is great and generally the right tool for this sort of thing. As an alternative, though, there are several Rust-based scripting languages that attempt to expose some of the power of the type system, etc., while being more amenable to dynamic loading, REPL, etc: http://libs.rs/scripting/

One that's not listed there but might be a good candidate for a Rust project is miri [1] since it's both interpreted and still Rust. It's still pretty rough, but the approach it takes should perform pretty well and won't require people to learn a new language.

[1] https://github.com/solson/miri

Re: Making a Game in Rust

#52
post #43

It would be nice to have a minimal gameish program as a example for people learning Rust. When I teach kids javascript I start with an etch-a-sketch. It's aided by a simple library to hide the mechanics of the HTML canvas element, context, etc. This allows it to be small enough that they can view it all in one go and build upon it. print("Draw with the arrow keys"); var cx=320; var cy=240; function update() { // the…

For simple pixel access and no primitives, https://github.com/emoon/rust_minifb is very compact and neat.

Otherwise rust-sdl2 is batteries included, there may be more ceremony than html5 canvas but it's easy to hide behind a simple interface. It has many simple examples.

But, like with C++, as long as the language doesn't come with a standard graphics library, I doubt the "official" books can really use graphics apps as a learning tool.

Re: Making a Game in Rust

#54

I would love to read a detailed explanation of the packaging process for iOS and Android.

The author should seriously consider factoring out his build scripts and start a crowd-funding campaign to open source it for X thousands of dollars. Hell, I don't even know Rust and I'll donate ten bucks.

The five platforms support is bloody impressive.

Re: Making a Game in Rust

#55
post #9
post #6

> The include_* macros are great for “packaging”. Being able to compile small assets directly into the binary and eschewing run time file loading is fantastic for a small game. For C/C++/etc devs looking for something similar, BFD objcopy supports an "-I binary". It will emit an object file with _binary_objfile_start, _binary_objfile_end and _binary_objfile_size symbols. But I have got to say that making it a languag…

Agreed. I code in C# and there's facility for bundling assets into the binary but they're handled at the project file level and not the C# file level, and this means the keys to access this binary content is not available as a compile-time constant. You're still just passing strings around and hoping they match. Having first-class language support for resource files looks fantastic.

I wonder how XNA's asset pipelines worked. I also wonder if you could "pack" a binary into an assembly by writing a tiny bit of IL around it.

Re: Making a Game in Rust

#56

Earlier quoted context omitted.

Now I have to rewrite my arcade game emulator in rust just so I can use that to load rom images...

include_bytes! is for compile-time inclusion of files though, not for runtime.

Yeah but when it only runs 15 games with a max size of 32K... But yeah it makes it non-distributable because it would then include the images.

Re: Making a Game in Rust

#58

I would love to read a detailed explanation of the packaging process for iOS and Android.

The author explains the process briefly here: https://gist.github.com/michaelfairley/d86137085307d2e5c16ee.... I think the most obvious pitfall is the native API calls for both platforms. Maybe a cross platform framework like PhoneGap for Rust?

Re: Making a Game in Rust

#59
post #52
post #43

It would be nice to have a minimal gameish program as a example for people learning Rust. When I teach kids javascript I start with an etch-a-sketch. It's aided by a simple library to hide the mechanics of the HTML canvas element, context, etc. This allows it to be small enough that they can view it all in one go and build upon it. print("Draw with the arrow keys"); var cx=320; var cy=240; function update() { // the…

For simple pixel access and no primitives, https://github.com/emoon/rust_minifb is very compact and neat. Otherwise rust-sdl2 is batteries included, there may be more ceremony than html5 canvas but it's easy to hide behind a simple interface. It has many simple examples. But, like with C++, as long as the language doesn't come with a standard graphics library, I doubt the "official" books can really use graphics apps…

Easy to hide behind a simple interface if you already know the programming language. My suggestion is that someone perhaps should do just that so that beginners don't have to learn how to construct a simple interface at the same time as they are learning the language.

The MiniFB code does seem to be a good starting point for this sort of thing.

Re: Making a Game in Rust

#60
post #4

Earlier quoted context omitted.

Really? How do they know what the representation of the object code was before compilation? Seems like if they had a whitelist it would be difficult to enforce.

The biggest problem I faced with Rust and macOS/iOS is related to Apple's requirement for bitcode on all submitted code to the App Store for Watch and appleTV applications. This internal Rust discussion focuses on it for more details: https://github.com/rust-lang/rust/issues/35968 This gist is that Apple is requiring bitcode, but isn't giving easy access to the LLVM version they use for their own tools. This means th…

It's not as bad as it sounds. The LLVM they ship in Xcode is basically stock, or at least it was in past releases where they posted the source - after all, Apple is the upstream for LLVM. And unlike the LLVM API, the LLVM bitcode format is stable and preserves backwards compatibility whenever possible, in the sense that newer versions of LLVM can read old bitcode. So there's a good chance that passing bitcode from rustc to Apple's tools will Just Work, and if it doesn't (like if rustc is using a newer LLVM than Xcode) then it should be fixable.
Post reply on HN