kon/lib.rs
1//! # Kon Engine
2//!
3//! A modular 2D game engine for Rust, built with a focus on ECS performance and simplicity.
4//!
5//! # Example
6//! ```ignore
7//! use kon::prelude::*;
8//!
9//! #[component]
10//! struct Position { x: f32, y: f32 }
11//!
12//! #[system]
13//! fn setup(ctx: &mut Context) {
14//! ctx.world_mut()
15//! .spawn()
16//! .insert(Position { x: 0.0, y: 0.0 })
17//! .tag("player")
18//! .id();
19//! }
20//!
21//! #[system]
22//! fn update(ctx: &mut Context) {
23//! if ctx.time.frame_count() == 60 {
24//! ctx.quit();
25//! }
26//! }
27//!
28//! fn main() {
29//! Kon::new()
30//! .add_plugin(DefaultPlugins)
31//! .add_startup_system(setup)
32//! .add_system(update)
33//! .run();
34//! }
35//! ```
36
37pub use kon_core;
38pub use kon_ecs;
39pub use kon_macros::{component, system};
40pub use log;
41
42use kon_core::Plugin;
43
44pub mod prelude {
45 //! Common imports for Kon Engine
46 pub use crate::DefaultPlugins;
47 pub use crate::{component, system};
48 pub use kon_core::{App, Context, Event, Events, Globals, Kon, Plugin, Time};
49 pub use kon_ecs::{ContextEcsExt, EcsPlugin, Entity, EntityBuilder, Query, World};
50}
51
52/// Engine version
53pub const VERSION: &str = env!("CARGO_PKG_VERSION");
54
55/// Default plugins bundle
56///
57/// Includes:
58/// - `EcsPlugin` - Entity Component System
59pub struct DefaultPlugins;
60
61impl Plugin for DefaultPlugins {
62 fn build(&self, app: &mut kon_core::App) {
63 app.add_plugin(kon_ecs::EcsPlugin);
64 }
65
66 fn is_plugin_group(&self) -> bool {
67 true
68 }
69}