Earlier quoted context omitted.
Dyon (from that link) looks very cool! I'd also like to add that JavaScript is another language used in this arena, and there is a crate with V8 bindings ( https://crates.io/crates/v8 ). Even Garry Newman (creator of Garry's mod) wrote that he believes JS would have been better than Lua for scripting: https://garry.tv/2014/08/16/i-fell-out-of-love-with-lua/
Yeah, Lua certainly has it quirks. However binding to JS is a huge endeavor. For instance that v8 crate doesn't easily expose a way to call Rust from JS which is trivial in Lua. Also the JS runtime is huge and the build system is complex. You can run Lua in ~400kb or less and LuaJIT tends to walk over any other jitted interpreted runtime.
Making a Game in Rust
111–120 of 125 posts
Re: Making a Game in Rust
#112Earlier quoted context omitted.
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.
I absolutely advocate using graphics and games as the hook to keep people interested in learning. [1] "The immediacy of many 8-bit computers was awesome. Instant boot to a graphics-ready command line and program editor. I was instantly hooked". And that's why, despite the really bad fit, I support the addition of a 2d std library to C++, and would do likewise for Go, Rust, etc.
Re: Making a Game in Rust
#113Earlier quoted context omitted.
If the type proved there could be no NaN, why would the check be needed?
0.0 is a finite number that yields NaN when divided by itself. The initial checking is not sufficient.
Wait, are +-Inf considered unordered? Edit: Nope. inf == inf, so you should only have to worry about NaN. https://is.gd/Xi5jdr
Re: Making a Game in Rust
#114Earlier quoted context omitted.
This tells me why I got downvotes, I replied to the wrong comment. The game wasn't written in rust, is was used in a texture and drawn on a wall.
The game that's the subject of the OP is written in Rust. The one in the Reddit thread linked elsewhere was only a texture.
Re: Making a Game in Rust
#115that's a great twist on the snake game. does rust compile to wasm?
Yes, Rust can compile to WASM. https://hackernoon.com/compiling-rust-to-webassembly-guide-4...
Re: Making a Game in Rust
#116Earlier quoted context omitted.
Yeah, Lua certainly has it quirks. However binding to JS is a huge endeavor. For instance that v8 crate doesn't easily expose a way to call Rust from JS which is trivial in Lua. Also the JS runtime is huge and the build system is complex. You can run Lua in ~400kb or less and LuaJIT tends to walk over any other jitted interpreted runtime.
While the performance definitely doesn't compare to LuaJIT, Duktape ( http://duktape.org/ ) could be a good target for Rust bindings - it's fairly small and available as a single-header/implementation library.
Re: Making a Game in Rust
#117Earlier quoted context omitted.
While include_bytes is nice, xxd -i in a makefile is pretty workable solution in the scale of things.
Fair point, however I believe the OP made the game work for many different OSes, and I don't think xxd or Makefiles are the best when you have to deal with Windows (whereas Rust's include_bytes! provides a platform-independent solution). I had never heard of xxd until your comment though, so thank you very much!
Re: Making a Game in Rust
#118Earlier quoted context omitted.
0.0 is a finite number that yields NaN when divided by itself. The initial checking is not sufficient.
So check on construction, when doing operations with other unchecked floats, and when dividing. Any other operations that could produce a NaN? Wait, are +-Inf considered unordered? Edit: Nope. inf == inf, so you should only have to worry about NaN. https://is.gd/Xi5jdr
Re: Making a Game in Rust
#119Earlier quoted context omitted.
Dyon (from that link) looks very cool! I'd also like to add that JavaScript is another language used in this arena, and there is a crate with V8 bindings ( https://crates.io/crates/v8 ). Even Garry Newman (creator of Garry's mod) wrote that he believes JS would have been better than Lua for scripting: https://garry.tv/2014/08/16/i-fell-out-of-love-with-lua/
Unfortunately, some of those syntax niceties the Garry's mod creator mentioned are things that have been identified as leading causes of bugs. ++ mutates a variable in place, has non-trivial pre/post behaviour (many junior devs don't understand it), and its brevity causes it to be used inline, which results in complex one liners. String concatenation using '+' is not considered to be a great feature in dynamically ty…
Yes, one of the things Perl got very right, and yet it is still brought up by people as evidence of what makes Perl look like line noise (along with == vs eq, which is the same thing, even if the problem is less troublesome in that case).
> So it feels a little like Lua is being criticised for making some good calls.
All too often languages (and aspects of them) are criticized mistanely as being worse when all that is presented is how they are different. All too often we vilify the unusual just for being unusual.
Re: Making a Game in Rust
#120Earlier quoted context omitted.
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!
Whilst an easy start is nice, any language that you can pick up with no effort just means you're learning the same language + paradigm that you already know with a few differing features (in go's case CSP). Nothing wrong with that, CSP is awesome etc I'm not a rust dev (definitely interested in picking it up though), but heavily into clojure and learning haskell slowly on the side. I hear this complaint a lot from pe…