Rust+Bevyのゲーム開発環境を構築

ダラダラしてたら年明けてた🤔
さっさとRustの開発環境作って、いい加減開発を進めるぞ
発端: https://zenn.dev/passio84/articles/rust-game-development-primer-202212121200

とりあえずRustをインスコするので公式Docを見てみる
LinuxやMacを使っている場合のインストールコマンド:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

curlコマンドでインストールしたくない、できるだけOSのパッケージマネージャーに一任したい人間なので、他のインストール方法に関するページに移動
下記の説明に該当するアンチパターンなのに、この先の説明はない模様
That page describes installation via rustup, a tool that manages multiple Rust toolchains in a consistent way across all platforms Rust supports. Why might one not want to install using those instructions?
- Preference for the system package manager. On Linux in particular, but also on macOS with Homebrew, MacPorts or pkgsrc, and Windows with Chocolatey or Scoop, developers sometimes prefer to install Rust with their platform's package manager.

とりあえずbrew上で "rust" を検索してみると、Formulaeに用意されてた
% brew search rust
==> Formulae
c2rust choose-rust rust rust-analyzer rustc-completion rustfmt rustscan rustup-init shadowsocks-rust uncrustify virustotal-cli rush
==> Casks
rustdesk uncrustifyx
If you meant "rust" specifically:
It was migrated from homebrew/cask to homebrew/core.
rustup-init
もあったし、あくまで推奨は rustup
でのインストールの模様
ただ、ざっくり調べてみた感じではHomebrew経由でも問題なさそうなので、今回は下記を実行
brew install rust

次に、ゲーム開発ライブラリである Bevy をインストール
こちらも公式ページを参考にする

サンプルのブロック崩しを実行できるみたい
git clone https://github.com/bevyengine/bevy
cd bevy
cargo run --example breakout
TOMLファイルを見てみたら他にもサンプルがいっぱいあった
vim Cargo.toml
# Vim search mode
/\[\[example\]\]
3Dポリゴン狐が走るやつもあった
かわいい
cargo run --example animated_fox

開発用ディレクトリを作成してGitリポジトリ化しつつ、cargoでBevyを依存ライブラリとして追加
mkdir poker-chips
cd poker-chips
git init
cargo init
cargo add bevy

続きのページを読む

IDEはrust-analyzerなるものがあるらしい
ちょうどVSCodeを使っているので、拡張機能をインストール
Code Editor / IDE
You can use any code editor you want, but we highly recommend one that has a rust-analyzer plugin. It's still in development, but it already provides top-tier autocomplete and code intelligence. Visual Studio Code has an officially supported rust-analyzer extension.

他に入れておくと良さそうなものあるかなーと検索したところ、おっけー氏の記事を発見
下記の通り、FormatterやLinterもありそう 👀
- cargo edit
- cargo watch
- Rustfmt
- Clippy