euv_engine/scene/trait.rs
1use crate::*;
2
3/// The base trait for all game scenes.
4///
5/// A scene encapsulates a self-contained portion of the game world,
6/// managing its own game objects, resources, and update logic.
7pub trait Scene {
8 /// Called once when this scene becomes the active scene.
9 fn on_enter(&mut self);
10
11 /// Called once when this scene is being replaced or removed.
12 fn on_exit(&mut self);
13
14 /// Called every fixed timestep to update game logic.
15 ///
16 /// # Arguments
17 ///
18 /// - `f64` - The delta time in seconds.
19 fn on_update(&mut self, delta_time: f64);
20
21 /// Called every render frame to draw the scene.
22 ///
23 /// # Arguments
24 ///
25 /// - `&CanvasRenderingContext2d` - The canvas rendering context.
26 fn on_render(&self, context: &CanvasRenderingContext2d);
27
28 /// Returns the name of this scene for identification.
29 ///
30 /// # Returns
31 ///
32 /// - `&str` - The scene name.
33 fn name(&self) -> &str;
34}