Live data from Hacker News

Making a Game in Rust

michaelfairley.com

11–20 of 125 posts

Re: Making a Game in Rust

#11
Great writeup. Eye opening that you can actually write iOS apps with rust. w00t, totally trying this for my next app. (It's a bit overly bit expensive for my liking but otherwise I would have given your game a shot).

Re: Making a Game in Rust

#12
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…

To embed binary assets into any language, write a program that emits the binary as a string containing hex codes.

E.g. bytes [0, 12, 99] would become "\x00\x0C\x63".

Almost every language has facilities to treat a string as a set of bytes, so this works basically everywhere. It's nice because you don't need any special language-level support for it.

Re: Making a Game in Rust

#13
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…

To embed binary assets into any language, write a program that emits the binary as a string containing hex codes. E.g. bytes [0, 12, 99] would become "\x00\x0C\x63". Almost every language has facilities to treat a string as a set of bytes, so this works basically everywhere. It's nice because you don't need any special language-level support for it.

While I do agree that it is possible to do something like that, I think we can all agree that the following (available in Rust) is soooooo much nicer:

    let stuff = include_bytes!("my.file");

Re: Making a Game in Rust

#14
> I had two or three false-start attempts at learning Rust where I’d spend a few hours with it, not get anything done, and put it down until a few months later

This sounds (sort of) encouraging. I was kind of expecting to learn it by putting in an hour here and there e.g. 2-4h/month. But I'm beginning to think that might not cut it...

Re: Making a Game in Rust

#16
post #5

Earlier quoted context omitted.

Note that I've obviously never written an iOS app, but I figured that Apple required you to submit the source of your app for their auditing process. Which sounds extreme, but this is Apple we're talking about. :)

There was indeed a rule at one point that apps had to be written in C, C++, or Objective-C. This was allegedly implemented in order to ban cross-compilers such as Flash compiler[0]. Presumably they would either require the source code to verify this, or inspect the compiled binary for some identifying feature. However, these rules don't exist in the current version of the guidelines[1]. [0] http://daringfireball.net/…

This rule got so much press 7 years ago that it will be one of those "truths" about a platform that never dies on internet forums, that and the Playstation platforms using OpenGL as their primary API...

Re: Making a Game in Rust

#17
Neat! I was just complaining about the lack of multiplatform Rust games proving out the concept. If only there were some consoles or handhelds on the list... although iOS/Android being on the list is somewhat encouraging.

Re: Making a Game in Rust

#18

Earlier quoted context omitted.

To embed binary assets into any language, write a program that emits the binary as a string containing hex codes. E.g. bytes [0, 12, 99] would become "\x00\x0C\x63". Almost every language has facilities to treat a string as a set of bytes, so this works basically everywhere. It's nice because you don't need any special language-level support for it.

While I do agree that it is possible to do something like that, I think we can all agree that the following (available in Rust) is soooooo much nicer: let stuff = include_bytes!("my.file");

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

Re: Making a Game in Rust

#19

Earlier quoted context omitted.

To embed binary assets into any language, write a program that emits the binary as a string containing hex codes. E.g. bytes [0, 12, 99] would become "\x00\x0C\x63". Almost every language has facilities to treat a string as a set of bytes, so this works basically everywhere. It's nice because you don't need any special language-level support for it.

While I do agree that it is possible to do something like that, I think we can all agree that the following (available in Rust) is soooooo much nicer: let stuff = include_bytes!("my.file");

While include_bytes is nice, xxd -i in a makefile is pretty workable solution in the scale of things.

Re: Making a Game in Rust

#20

> I had two or three false-start attempts at learning Rust where I’d spend a few hours with it, not get anything done, and put it down until a few months later This sounds (sort of) encouraging. I was kind of expecting to learn it by putting in an hour here and there e.g. 2-4h/month. But I'm beginning to think that might not cut it...

Go is a language that you can absolutely learn like that, and it's pretty amazing. (Python, too)

Rust ... isn't. I love Rust, but you do need to put some dedicated time into learning it. We're hoping to improve this!

Post reply on HN