Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rusty_ache::engine::Engine;
use rusty_ache::engine::scene::game_object::GameObject;
use rusty_ache::engine::scene::game_object::components::script::Script;
use rusty_ache::engine::scene::game_object::position::Position;
use rusty_ache::interface::{create_obj_with_img, init_engine, init_scene};
use rusty_ache::interface::{create_obj_with_img, init_end_scene, init_engine, init_scene};
use rusty_ache::screen::{HEIGHT, WIDTH};

fn main() {
Expand All @@ -28,11 +28,27 @@ fn main() {
],
main_ship_obj,
);
let mut engine = init_engine(scene, WIDTH, HEIGHT);

let end_scene = init_end_scene("src/bin/resources/game_over.jpg", None);
let mut engine = init_engine(scene, end_scene, WIDTH, HEIGHT);

let main_pos_arc = engine.main_pos.clone();
let end_scene_flag = engine.is_end_scene_active.clone();
std::thread::spawn(move || {
loop {
let (x, y) = *main_pos_arc.read().unwrap();
println!("position of main object is ({}, {})", x, y);
if x > 150 {
end_scene_flag.store(true, std::sync::atomic::Ordering::SeqCst);
}
}
});

engine.render().unwrap();
engine.run().unwrap()
}

#[derive(Clone)]
pub struct MyScript {
is_downed: bool,
}
Expand Down Expand Up @@ -61,6 +77,10 @@ impl Script for MyScript {
self.is_downed = false;
}
}

fn clone_box(&self) -> Box<dyn Script + Send + Sync> {
Box::new(self.clone())
}
}

#[cfg(test)]
Expand Down
Binary file added src/bin/resources/empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/bin/resources/game_over.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading