Fyrox3D and 2D game engine written in Rust项目地址:https://gitcode.com/gh_mirrors/fy/Fyrox
Fyrox 是一个功能丰富的游戏引擎,使用 Rust 语言编写。它支持 2D 和 3D 游戏开发,并提供了一个场景编辑器,方便开发者进行游戏内容的创建和管理。Fyrox 引擎的前身是 rg3d,自 2019 年以来一直在积极开发中。
git clone https://github.com/FyroxEngine/Fyrox.git
cd Fyrox
Fyrox 提供了多个示例项目,可以帮助你快速了解和上手引擎的使用。以下是一个简单的示例代码,展示如何创建一个基本的 3D 场景:
use fyrox::{
core::pool::Handle,
engine::{Engine, EngineInitParams},
event::{Event, WindowEvent},
event_loop::ControlFlow,
plugin::{Plugin, PluginConstructor, PluginGroup, PluginGroupConstructor},
scene::{Scene},
utils::{log::init_log, resource::load_texture},
};
struct GamePlugin;
impl Plugin for GamePlugin {
fn on_init(&mut self, engine: &mut Engine, _scene: Handle) {
// 在这里添加你的初始化代码
}
fn on_update(&mut self, engine: &mut Engine, _scene: Handle) {
// 在这里添加你的更新代码
}
fn on_event(&mut self, _engine: &mut Engine, _event: &Event<()>, _control_flow: &mut ControlFlow) {
// 在这里处理事件
}
}
struct GamePluginConstructor;
impl PluginConstructor for GamePluginConstructor {
fn create_instance(&self, _: &mut Engine) -> Box {
Box::new(GamePlugin)
}
}
struct GamePluginGroup;
impl PluginGroupConstructor for GamePluginGroup {
fn create_plugin_group(&self) -> Box {
Box::new(GamePluginConstructor)
}
}
fn main() {
init_log();
let mut engine = Engine::new(EngineInitParams {
plugin_group_constructors: vec![Box::new(GamePluginGroup)],
..Default::default()
});
engine.run();
}
Fyrox 生态系统中包含多个相关项目,这些项目扩展了 Fyrox 的功能,提供了更多的工具和资源:
通过这些生态项目,开发者可以更全面地利用 Fyrox 引擎进行游戏开发,提高开发效率和游戏质量。
Fyrox3D and 2D game engine written in Rust项目地址:https://gitcode.com/gh_mirrors/fy/Fyrox