Skip to main content

game_toolkit/
lib.rs

1//! game-toolkit: a game-jam toolkit for 2D and 3D.
2//!
3//! This is the umbrella entry-point crate. Depend on `game-toolkit` and write
4//! `use game_toolkit::prelude::*;` to pull in the runtime types from the `game-toolkit-*`
5//! crates behind one dependency. Optional features: `ui`, `aseprite`, `ecs`, `synth`,
6//! `vector`, `crt`, `indexed`, `compute`.
7//!
8//! New here? The [`guide`] walks through the whole API on one page.
9
10#![forbid(unsafe_code)]
11
12#[cfg(feature = "aseprite")]
13mod aseprite_ext;
14
15pub mod guide;
16
17/// GPU compute helpers (feature `compute`): [`Kernel`](compute::Kernel),
18/// [`PingPong`](compute::PingPong), [`ReadbackRing`](compute::ReadbackRing),
19/// [`StorageTexture`](compute::StorageTexture) and
20/// [`ComputeSubmitter`](compute::ComputeSubmitter). The main types are also in the prelude.
21#[cfg(feature = "compute")]
22pub use game_toolkit_compute as compute;
23
24/// Everything you need to write a game: `use game_toolkit::prelude::*;`.
25pub mod prelude {
26    pub use anyhow;
27    pub use anyhow::Result;
28    pub use winit;
29
30    pub use game_toolkit_assets::Assets;
31    pub use game_toolkit_audio::{
32        Audio, AudioError, AudioStream, PlayOptions, SoundHandle, SoundId, StereoStream,
33        StreamHandle, kira,
34    };
35    pub use game_toolkit_core::{AppConfig, Context, Game, GameEvent, Rng, Time, asset_root, run};
36    pub use game_toolkit_gfx::{
37        Align, BAYER_WGSL, BitmapFont, BlendMode, Camera, Camera2D, Camera3D, CircleInstance,
38        Color, CustomPass, DeviceRequirementsError, Frame, Glyph, Graphics, GridLayout, Layer,
39        Mat4, MeshId, MeshInstance, MeshVertex, Painter, PostEffect, PostEffectId, PostPass,
40        PostStage, ScaleFilter, ScaleMode, ShaderEffect, SpriteInstance, TextureId, TextureWrap,
41        Tilemap, transform, wgpu,
42    };
43    pub use game_toolkit_input::{
44        Axis, Button, Gamepad, GamepadId, Input, Key, MouseButton, PointerMapping, Touch,
45    };
46
47    #[cfg(feature = "ui")]
48    pub use game_toolkit_ui::{self, Ui, egui};
49
50    #[cfg(feature = "aseprite")]
51    pub use crate::aseprite_ext::LoadAseprite;
52    #[cfg(feature = "aseprite")]
53    pub use game_toolkit_aseprite::{
54        self, Animation, AnimationPlayer, Direction, FrameRect, SpriteSheet,
55    };
56
57    #[cfg(feature = "synth")]
58    pub use game_toolkit_audio::{Synth, SynthHandle, synth, synthie};
59
60    #[cfg(feature = "ecs")]
61    pub use game_toolkit_ecs::{self, ChannelQueue, Vec2};
62
63    #[cfg(feature = "vector")]
64    pub use game_toolkit_gfx::vello;
65
66    #[cfg(feature = "crt")]
67    pub use game_toolkit_gfx::{BloomSource, CrtBeam, CrtEffect, CrtMask, CrtSettings, CrtSource};
68
69    #[cfg(feature = "indexed")]
70    pub use game_toolkit_gfx::{INDEX_WGSL, IndexedImage, Palette, PaletteCycle, PaletteCycleId};
71
72    #[cfg(feature = "compute")]
73    pub use game_toolkit_compute::{
74        self, Binding, ComputeSubmitter, Kernel, PingPong, PingPongBindGroups, ReadbackRing,
75        StorageTexture,
76    };
77}