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, StreamHandle, kira,
33    };
34    pub use game_toolkit_core::{AppConfig, Context, Game, GameEvent, Rng, Time, asset_root, run};
35    pub use game_toolkit_gfx::{
36        Align, BAYER_WGSL, BitmapFont, BlendMode, Camera, Camera2D, Camera3D, CircleInstance,
37        Color, CustomPass, DeviceRequirementsError, Frame, Glyph, Graphics, GridLayout, Layer,
38        Mat4, MeshId, MeshInstance, MeshVertex, Painter, PostEffect, PostEffectId, PostPass,
39        PostStage, ScaleFilter, ScaleMode, ShaderEffect, SpriteInstance, TextureId, TextureWrap,
40        Tilemap, transform, wgpu,
41    };
42    pub use game_toolkit_input::{
43        Axis, Button, Gamepad, GamepadId, Input, Key, MouseButton, PointerMapping, Touch,
44    };
45
46    #[cfg(feature = "ui")]
47    pub use game_toolkit_ui::{self, Ui, egui};
48
49    #[cfg(feature = "aseprite")]
50    pub use crate::aseprite_ext::LoadAseprite;
51    #[cfg(feature = "aseprite")]
52    pub use game_toolkit_aseprite::{
53        self, Animation, AnimationPlayer, Direction, FrameRect, SpriteSheet,
54    };
55
56    #[cfg(feature = "synth")]
57    pub use game_toolkit_audio::{Synth, SynthHandle, synth, synthie};
58
59    #[cfg(feature = "ecs")]
60    pub use game_toolkit_ecs::{self, ChannelQueue, Vec2};
61
62    #[cfg(feature = "vector")]
63    pub use game_toolkit_gfx::vello;
64
65    #[cfg(feature = "crt")]
66    pub use game_toolkit_gfx::{BloomSource, CrtEffect, CrtMask, CrtSettings};
67
68    #[cfg(feature = "indexed")]
69    pub use game_toolkit_gfx::{INDEX_WGSL, IndexedImage, Palette, PaletteCycle, PaletteCycleId};
70
71    #[cfg(feature = "compute")]
72    pub use game_toolkit_compute::{
73        self, Binding, ComputeSubmitter, Kernel, PingPong, PingPongBindGroups, ReadbackRing,
74        StorageTexture,
75    };
76}