|
|
|
|
|
by Lerc
3333 days ago
|
|
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 arrow keys have key codes 37,38,39 and 40
if (keyIsDown(38)) { cy-=1; }
if (keyIsDown(40)) { cy+=1; }
if (keyIsDown(37)) { cx-=1; }
if (keyIsDown(39)) { cx+=1; }
fillCircle(cx,cy,6);
}
run(update);
There might be merit in writing one of these in every language (and a companion that uses the mouse), maybe placing it on github . With a really simple program like this you can focus on learning the language while making something. It's a tough job figuring out how to learn a language while simultaneoulsy learning how to write the boilerplate needed to get something onscreen. |
|
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.