< 返回我的博客

rdigua 发表于 2020-06-20 17:55

Tags:rust,game,sdl

Installation 安装

To get started with Tetra, you'll need a couple of things installed: 首先在采用Tetra之前,你需要做的一些准备。

  • The latest stable version of Rust
    最新版本的Rust稳定版
  • The SDL 2.0 development libraries
    SDL 2.0 开发包
  • The ALSA development libraries (only required on Linux)
    如果是Linux环境,还应该安装 ALSA 开发包

#Installing Rust 安装Rust

Installing Rust is pretty simple - just go to the website and download the Rustup toolchain manager.
安装Rust很简单,只需要去 Rust 网站 下载 Rustup 交叉编译工具链管理软件 网站

Note that if you're developing on Windows with the default toolchain, you'll also need to install the Microsoft Visual C++ Build Tools, as Rust uses the MSVC linker when building. 提醒一下Windows环境下的开发者,如果你选择MSVC Rust工具链,你需要一点特殊准备:安装visual-studio-2017 网站

#Installing SDL 2.0

Tetra uses SDL for windowing and input, so you will need to have both the runtime and development libraries installed.
Windows环境下的Tetra配置 需要同时安装SDL 的开发包和运行库。

INFO 相关信息

The instructions below are adapted from the README of the sdl2 crate - further information can be found there.
下面的说明来自于Rust SDL开发包 参见:sdl2

#Windows Windows

If you're using the default MSVC Rust toolchain:
如果你选择MSVC Rust 开发环境:

  1. Go to the SDL website and download the Visual C++ version of the development libraries.
    首先去SDL 网站 下载相关支持 并且安装 Visual C++ 开发包
  2. Copy the .lib files from the SDL2-2.0.x/lib/x64 folder of the zip to the %USERPROFILE/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc/lib folder on your machine. If you are building on a beta/nightly toolchain, adjust the location accordingly.
    之后,从解压缩后的SDL2-2.0.x/lib/x64目录下拷贝所有文件到本地的%USERPROFILE/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc/lib目录下。 注意一下开发版本 nightly和稳定版目录的差异。

If you're using the GNU-based Rust toolchain:
GNU环境:

  1. Go to the SDL website and download the MinGW version of the development libraries.
    首先去SDL 网站 下载相关支持
  2. Copy the .lib files from the SDL2-2.0.x/x86_64-w64-mingw32/lib folder of the zip to the %USERPROFILE/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib folder on your machine. If you are building on a beta/nightly toolchain, adjust the location accordingly.
    同样,从解压缩后的SDL2-2.0.x/x86_64-w64-mingw32/lib目录下拷贝所有文件到本地的%USERPROFILE/.rustup/toolchains/stable-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib目录下。 注意一下开发版本 nightly和稳定版目录的差异。

When starting a new Tetra project, you will also need to make sure that SDL2.dll is present in the root of your project (i.e. the directory where you cargo run). You will also need to provide it alongside your game's executable when distributing it to players. Your game will not start if it is missing!
开发一个新的Tetra项目时候,需要确保SDL2.dll工程目录下,并且当发布的时候也需要一起打包。

You can download SDL2.dll from the 'Runtime Binaries' section of the SDL website - pick the version that corresponds to your system architecture.
SDL2.dll可以从 'Runtime Binaries' section of the SDL website 网站下载, 注意保持版本一致。

#Mac 苹果环境

The easiest way to install SDL is via Homebrew:
通过Homebrew 直接安装:

brew install sdl2

You will also need to add the following to your ~/.bash_profile, if it is not already present.
~/.bash_profile文件里加入下面内容, 如果文件不存在就创建一个。

export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"

#Linux Linux

The SDL development libraries are distributed through most Linux package managers - here are a few examples:
SDL开发包可以通过Linux 软件包管理工具安装 例:

# Ubuntu/Debian
sudo apt install libsdl2-dev

# Fedora/CentOS
sudo yum install SDL2-devel

# Arch Linux
sudo pacman -S sdl2

#Installing ALSA (Linux only) Linux环境下的特殊要求

On Linux, ALSA is used as the audio backend, so you will also need the ALSA development libraries installed. Similar to SDL, you can find these libraries on most Linux package managers:
在 Linux 上,采用ALSA作音频后端,因此您还需要安装 ALSA 开发库。与 SDL 类似,您可以在大多数 Linux 包管理器中找到这些库:

# Ubuntu/Debian
sudo apt install libasound2-dev

# Fedora/CentOS
sudo yum install alsa-lib-devel

# Arch Linux
sudo pacman -S alsa-lib


LICENSE

Copyright 2020 Joe Clay

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

评论区

写评论

还没有评论

1 共 0 条评论, 1 页