#opengl #sdl2 #game-engine

d7engine

使用 SDL2 和 OpenGL 的 Rust 游戏引擎

21 个稳定版本

1.1.5 2023年4月1日
1.1.4 2023年3月19日
1.1.3 2023年2月26日
1.0.12 2023年1月31日
1.0.5 2022年9月26日

#118 in 图形API

Download history 48/week @ 2024-03-30 6/week @ 2024-04-06 290/week @ 2024-04-27 5/week @ 2024-05-04

69 每月下载量

MIT 许可证

110KB
2.5K SLoC

d7engine

Markus Dick 的项目

d7engine 是一个用于娱乐的自制游戏引擎。

安装

确保您已通过以下方式在您的电脑上安装了 Rust:

cargo version

或者使用官方 Rust 安装指南安装 Rust。

创建一个新项目

cargo new your_game_name

并将引擎添加到项目中

cd your_game_name
cargo add d7engine

基本设置

//#![windows_subsystem = "windows"]
use d7engine::*;

struct Runt {
    components: ComponentContainer,
    camera: Transform,
}

impl Runtime for Runt {
    fn load(&mut self) {
        let color = Color::rgb(255, 0, 0);
        let mut rect1 = Component::rect().unwrap();
        rect1.set_color(&color);
        rect1.set_dim(100.0, 100.0);
        rect1.transform.set(50.0, 50.0, 0.0);
        self.components.insert("1", rect1);
    }

    fn draw(&mut self, draw: &Draw) {
        self.components.draw(draw, &self.camera).unwrap();
    }
}

fn main() {
    init(Config::default(), &mut Runt{
        components: ComponentContainer::new(),
        camera: Transform::new(),
    });
}

依赖项

~24–36MB
~550K SLoC