Something went wrong. Try again.
🎠 Powerfull and simple 2D game engine with ecs based on raylib
Something went wrong. Try again.
Files
README.md
🎠 Carousel #
Powerfull and simple data-driven 2D game engine with ecs built using raylib for graphics and rodio for audio, designed for peak performance.
Example #
use carousel::{
core::{
Game, State,
color::Color,
settings::{
ClockSettings, DebugSettings, DrawSettings, PhysicsSettings, Settings, StageSettings,
WindowSettings,
},
},
stage::basic::{Position, Shape, ShapeKind},
};
struct MyGame {
a: f32,
}
impl Game for MyGame {
fn start(&mut self, ctxt: &mut rail::core::ctxt::Ctxt) {
let _ = ctxt
.world
.entity()
.with(Position(360, 240))
.with(Shape(ShapeKind::Circle(10.0), Color::GREEN))
.spawn();
}
fn update(&mut self, ctxt: &mut rail::core::ctxt::Ctxt) {
let center_x = 360.0;
let center_y = 240.0;
let radius = 100.0;
let x = center_x + self.a.cos() * radius;
let y = center_y + self.a.sin() * radius;
ctxt.world
.query()
.with::<Position>()
.perform()
.iter()
.for_each(|e| {
*ctxt.world.get_mut::<Position>(*e).unwrap() =
Position(x.round() as i32, y.round() as i32);
});
self.a += 0.05;
}
}
fn main() {
let game = MyGame { a: 0f32 };
let mut state = State::new(
game,
Settings::new(
ClockSettings::new(30.0),
WindowSettings::new("Hello, world", 720, 480),
StageSettings::new(DrawSettings::new(Color::WHITE)),
PhysicsSettings::default(),
DebugSettings,
),
);
state.start_game();
}
🗺️ Check out our roadmap: #
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
·
Copy SHA
- Rust 100%