schule-pong/src/main.rs

26 lines
740 B
Rust
Raw Normal View History

2024-02-22 18:10:37 +01:00
use std::rc::Rc;
use engine::{
objs::{MovingRect, Object, Rect},
Engine,
};
2024-02-02 08:52:26 +01:00
fn main() {
2024-02-22 18:10:37 +01:00
let mut engine = Engine::new();
let rect_id = engine.insert_into_world(Rc::new(MovingRect::square(0, 0, 1)));
engine
.set_render_fn(|ctx, world, timer| {
println!("t: {}", timer.game_time_passed());
let obj = Rc::get_mut(world.get_mut(0)).unwrap();
obj.update_pos(
((timer.game_time_passed().sin() + 1.0) * 256.) as u32,
((timer.game_time_passed().cos() + 1.0) * 256.) as u32,
);
obj.display(ctx)
// Rect::square((timer.game_time_passed() * 20.) as u32, 0, 200).display(ctx);
2024-02-02 08:52:26 +01:00
})
2024-02-22 13:01:00 +01:00
.run();
2024-02-02 08:52:26 +01:00
}
2024-02-22 11:14:40 +01:00
2024-02-22 18:10:37 +01:00
mod engine;